Opening Excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need a little help with some code opening a excel file. What I need is
code that will allow an end-user to open an excel file depending on what data
is selected or input in a combo box.

I have tried serveral differant routines that have worked for me in the
past, but with no luck.

Thanks

Mark Koons
TPM Corrdinator
Waterloo Industries
 
Mark,

If you are asking for some outside help, I can help you. My fees are very
reasonable.
 
I need a little help with some code opening a excel file. What I need is
code that will allow an end-user to open an excel file depending on what data
is selected or input in a combo box.

I have tried serveral differant routines that have worked for me in the
past, but with no luck.

Thanks

Mark Koons
TPM Corrdinator
Waterloo Industries

What exactly is the data in the combo box.
Let's assume it's the name (Text) of an Excel file, and there are 3
choices.

Code the Combo box AfterUpdate event:

If Me!ComboName = "DailySales" Then
Application.FollowHyperlink "YourPathToFile\" & Me.ComboName & "xls"
ElseIf Me!ComboName = "ItemCosts" Then
Application.FollowHyperlink "YourPathToFile\" & Me.ComboName & "xls"
Else
Application.FollowHyperlink "YourPathToFile\" & Me.ComboName & "xls"
End If

Adjust the actual coding as needed.
If you also wish to close the current database when opening the
spreadsheet, add
DoCmd.Quit
after the End If
 
I find the following shell command the most consistent method


params = """" & LaunchIt & """"

WindowID = Shell("EXCEL.EXE " & params, 1)


The var LaunchIt would contain the file location. The reason I put it into
the var params instead of directly into the shell command is because
launching excel from the shell command does not like to have spaces in the
name/loaction. the following will also cause errors with excel.
Shell("EXCEL.EXE c:\ new folder\new excel file.xls", 1) creates an error,
so does
Shell("EXCEL.EXE" "c:\ new folder\new excel file.xls", 1) ir any other
combination
 
Unless Excel.exe is located in one of the folders pointed to by the PATH
environment variable, you need to provide the complete path to it.
 
Back
Top