mkofler
02-28-2013, 09:02 PM
Hi
I have a User Form where the user can select various procedures to run. The procedures process various parts of a Word document, headers, footers, styles etc. There are about 60 procedures that the user can choose.
The User Form has a List Box where I want to display various messages while each procedure is running.
Each procedure uses the AddItem method of the List Box object to display a message in the List Box. The List Box has a Run button the user clicks to run the selected procedures. Here's the basic structure:
Sub UserFormInitialise() ' Initialize User Form
ProcedureArray= Array(Procedure1, Procedure2..., Procedurenn)
Load UserForm
UserForm.show VbModeless
End Sub
Sub UserForm_Run_Button_Click() ' Click event for Run button on User Form
Call RunProcedureSelectedByUser() '
End Sub
Sub RunProcedureSelectedByUser() ' Runs the procedures selected by user
For counter = 0 To UBound(ProcedureArray)
Application.Run ProcedureArray(counter)
Next counter
End Sub
Sub RunProcedure1()
do_someprocessing_on_Word_Document
userform.Listbox1.AddItem "A message"
End Sub
Sub RunProcedure2()
do_someprocessing_on_Word_Document
userform.Listbox1.AddItem "Another message"
End Sub
Sub RunProcedure2()...
Sub RunProcedure3()...
However the problem is that the all the messages are added to List Box after all the macros that process the Word document have finished running.
I would like to display each message in the List Box as each macro runs so the user has information about what is running and what is being processed.
It seems that while the macros are processing the Word document, the List Box on the User Form does not get focus, even though I have tried to set the focus on the User Form and List Box.
So is the problem:
The structure - Because the code that processes the Word document is in a separate module from the User Form code.
A limitation of VBA - User form can't have focus until other procedures finish?
I need to set the focus for the User for/List box somewhere specific - change event for the List Box perhaps?Can anybody suggest a way I can display the messages in the List Box as each macro is running?
I have a User Form where the user can select various procedures to run. The procedures process various parts of a Word document, headers, footers, styles etc. There are about 60 procedures that the user can choose.
The User Form has a List Box where I want to display various messages while each procedure is running.
Each procedure uses the AddItem method of the List Box object to display a message in the List Box. The List Box has a Run button the user clicks to run the selected procedures. Here's the basic structure:
Sub UserFormInitialise() ' Initialize User Form
ProcedureArray= Array(Procedure1, Procedure2..., Procedurenn)
Load UserForm
UserForm.show VbModeless
End Sub
Sub UserForm_Run_Button_Click() ' Click event for Run button on User Form
Call RunProcedureSelectedByUser() '
End Sub
Sub RunProcedureSelectedByUser() ' Runs the procedures selected by user
For counter = 0 To UBound(ProcedureArray)
Application.Run ProcedureArray(counter)
Next counter
End Sub
Sub RunProcedure1()
do_someprocessing_on_Word_Document
userform.Listbox1.AddItem "A message"
End Sub
Sub RunProcedure2()
do_someprocessing_on_Word_Document
userform.Listbox1.AddItem "Another message"
End Sub
Sub RunProcedure2()...
Sub RunProcedure3()...
However the problem is that the all the messages are added to List Box after all the macros that process the Word document have finished running.
I would like to display each message in the List Box as each macro runs so the user has information about what is running and what is being processed.
It seems that while the macros are processing the Word document, the List Box on the User Form does not get focus, even though I have tried to set the focus on the User Form and List Box.
So is the problem:
The structure - Because the code that processes the Word document is in a separate module from the User Form code.
A limitation of VBA - User form can't have focus until other procedures finish?
I need to set the focus for the User for/List box somewhere specific - change event for the List Box perhaps?Can anybody suggest a way I can display the messages in the List Box as each macro is running?