S
Supe
I am working in a database that someone else had created where if you select
a customer from a list and hit a button it bring up that file for you. From
the code I have attached he had it set up to pull Excel files. Is there a
way to change this code to where it would pull either Excel or Word files?
Private Sub cmdStoreList_Click()
On Error GoTo errhandler
Dim oBook As Object
If cnt = 0 Then
If cust = "" Then
MsgBox "File Error. Please select a customer, then try again."
Exit Sub
Else
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Open("S:\Stardust Planner\Store
Lists\" & cust & ".xls")
oExcel.Visible = True
cnt = 1
End If
Else
oExcel.Quit
If cust = "" Then
MsgBox "File Error. Please select a customer, then try again."
Exit Sub
Else
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Open("S:\Stardust Planner\Store
Lists\" & cust & ".xls")
oExcel.Visible = True
cnt = 1
End If
End If
errhandler:
If Err.Number = 1004 Then
MsgBox "File is not available at the moment. Please make sure that
it is present and try again.", vbInformation, "Information"
End If
End Sub
a customer from a list and hit a button it bring up that file for you. From
the code I have attached he had it set up to pull Excel files. Is there a
way to change this code to where it would pull either Excel or Word files?
Private Sub cmdStoreList_Click()
On Error GoTo errhandler
Dim oBook As Object
If cnt = 0 Then
If cust = "" Then
MsgBox "File Error. Please select a customer, then try again."
Exit Sub
Else
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Open("S:\Stardust Planner\Store
Lists\" & cust & ".xls")
oExcel.Visible = True
cnt = 1
End If
Else
oExcel.Quit
If cust = "" Then
MsgBox "File Error. Please select a customer, then try again."
Exit Sub
Else
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Open("S:\Stardust Planner\Store
Lists\" & cust & ".xls")
oExcel.Visible = True
cnt = 1
End If
End If
errhandler:
If Err.Number = 1004 Then
MsgBox "File is not available at the moment. Please make sure that
it is present and try again.", vbInformation, "Information"
End If
End Sub