T
Travis
This is a sub to open the File Open dialog box.
I've copied and pasted this out of an Access VBA book (Microsoft Access
VBA programming for the Absolute Beginner), and when I run it Access
stops at lstFiles.AddItem complaining "Compile Error: variable not
defined".
I've looked up listFiles.Additem in Google and it does appear to be a
legit VBA object and method. So why is Access 2003 telling me it
hasn't heard of it?
Private Sub Command15_Click()
'Declare a FileDialog object variable.
Dim myFileDialog As FileDialog
'Declare a variant to hold each file selected.
Dim vFileSelected As Variant
'Create a FileDialog object as an Open dialog window.
Set myFileDialog = Application.FileDialog(msoFileDialogOpen)
'If the user didn't press Cancel, process each selection.
If myFileDialog.Show = -1 Then
For Each vFileSelected In myFileDialog.SelectedItems
lstFiles.AddItem vFileSelected
Next vFileSelected
Else
' The user pressed Cancel.
MsgBox "No files selected."
End If
'Set the myFileDialog object variable to Nothing.
Set myFileDialog = Nothing
End Sub
Travis
I've copied and pasted this out of an Access VBA book (Microsoft Access
VBA programming for the Absolute Beginner), and when I run it Access
stops at lstFiles.AddItem complaining "Compile Error: variable not
defined".
I've looked up listFiles.Additem in Google and it does appear to be a
legit VBA object and method. So why is Access 2003 telling me it
hasn't heard of it?
Private Sub Command15_Click()
'Declare a FileDialog object variable.
Dim myFileDialog As FileDialog
'Declare a variant to hold each file selected.
Dim vFileSelected As Variant
'Create a FileDialog object as an Open dialog window.
Set myFileDialog = Application.FileDialog(msoFileDialogOpen)
'If the user didn't press Cancel, process each selection.
If myFileDialog.Show = -1 Then
For Each vFileSelected In myFileDialog.SelectedItems
lstFiles.AddItem vFileSelected
Next vFileSelected
Else
' The user pressed Cancel.
MsgBox "No files selected."
End If
'Set the myFileDialog object variable to Nothing.
Set myFileDialog = Nothing
End Sub
Travis