I am trying to create a UserForm for our customer service reps to use with a template when sending a customer a receipt.
The receipt will sometimes need multiple order lines, so I decided to use a table within Word for the order lines.
This is all being done in Word.
In order to begin figuring this out, I have decided to start simple with a 4 cell table prototype using the following:
Now, the experimental UserForm I created has two ComboBoxes: cboPubName and cboTerm.
The UserForm also has three Command Buttons: cmdAddOrder, cmdSubmit, and cmdCancel.
It is my goal to enter a Do...Loop when cmdAddOrder is clicked and exit the loop when cmdSubmit or cmdCancel is clicked.
The Do...Loop would:
1) Unload the data selected from the two Combo Boxes into the first two adjacent cells of the table
2) Move down one row on the table
3) Clear out the two Combo Boxes on the UserForm
4) Set Focus on cboPubName
5) Loop to step one
When the Submit button is clicked, it would unload whatever other controls are on the userform that don't go in the table and it would exit the Loop.
When the Cancel button is clicked, it would just cancel the whole operation.
I am having a hard time getting my head wrapped around what needs to be done here.
The main thing is how to dump the Combo Box data into the cells using the cmdAddOrder button, and how to move incrementally through the columns and rows.
I would really appreciate some guidance here. I need it in the simplest terms, as I am still learning and have only been working with VBA for about a week.
The receipt will sometimes need multiple order lines, so I decided to use a table within Word for the order lines.
This is all being done in Word.
In order to begin figuring this out, I have decided to start simple with a 4 cell table prototype using the following:
Code:
Set myRange = ActiveDocument.Range(MoveEnd)
ActiveDocument.Tables.Add Range:=myRange, NumRows:=2, NumColumns:=2
Now, the experimental UserForm I created has two ComboBoxes: cboPubName and cboTerm.
The UserForm also has three Command Buttons: cmdAddOrder, cmdSubmit, and cmdCancel.
It is my goal to enter a Do...Loop when cmdAddOrder is clicked and exit the loop when cmdSubmit or cmdCancel is clicked.
The Do...Loop would:
1) Unload the data selected from the two Combo Boxes into the first two adjacent cells of the table
2) Move down one row on the table
3) Clear out the two Combo Boxes on the UserForm
4) Set Focus on cboPubName
5) Loop to step one
When the Submit button is clicked, it would unload whatever other controls are on the userform that don't go in the table and it would exit the Loop.
When the Cancel button is clicked, it would just cancel the whole operation.
I am having a hard time getting my head wrapped around what needs to be done here.
The main thing is how to dump the Combo Box data into the cells using the cmdAddOrder button, and how to move incrementally through the columns and rows.
I would really appreciate some guidance here. I need it in the simplest terms, as I am still learning and have only been working with VBA for about a week.