willyboy58
Technical User
I have six command buttons on a worksheet. Three to print and three to preview. Right now they all work as desired in printing and/or previewing their respective worksheets. I am wanting to add some code to each button to open a List Box and display the files in a directory in which to print or preview.
Example: I have FileA, FileB and FileC and the user selects the Preview Invoices button. The List Box appears with the three files listed. The user then selects the desired file and the code executes (fires?) to preview the selected worksheets in the selected file.
The following code is from VBA help:
Dim EntryCount As Single
Private Sub CommandButton1_Click()
EntryCount = EntryCount + 1
ListBox1.AddItem (EntryCount & " - Selection"
End Sub
The following is my attempt:
Public ReportMonth As String
Sub AddToListBox()
ReportMonth = "Prop1" & ReportMonth & ".xls"
ListBox1.AddItem (ReportMonth)
'below is the Path for saving the new file
Workbooks("Propxfer".Close savechanges:=False
End Sub
I receive the message “Object Required”. Isn’t the ListBox1 the object? What is the difference between my code and Help’s? There is definitely a list box on my worksheet. How can I check the name to make sure that it is ListBox1?
Would this be easier using a Dialog box?
TIA
Bill
Example: I have FileA, FileB and FileC and the user selects the Preview Invoices button. The List Box appears with the three files listed. The user then selects the desired file and the code executes (fires?) to preview the selected worksheets in the selected file.
The following code is from VBA help:
Dim EntryCount As Single
Private Sub CommandButton1_Click()
EntryCount = EntryCount + 1
ListBox1.AddItem (EntryCount & " - Selection"
End Sub
The following is my attempt:
Public ReportMonth As String
Sub AddToListBox()
ReportMonth = "Prop1" & ReportMonth & ".xls"
ListBox1.AddItem (ReportMonth)
'below is the Path for saving the new file
Workbooks("Propxfer".Close savechanges:=False
End Sub
I receive the message “Object Required”. Isn’t the ListBox1 the object? What is the difference between my code and Help’s? There is definitely a list box on my worksheet. How can I check the name to make sure that it is ListBox1?
Would this be easier using a Dialog box?
TIA
Bill