Open Excel spreadsheet from Access form

G

Guest

Hi,

I want to open an Excel spreadsheet from an Access form using Call Shell.
This is what I have so far:

stAppName = "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE " &
Chr(34) & "C:\Documents and Settings\worksheet 1.xls" & Chr(34)

Call Shell(stAppName, 1)

Only problem is, I want to prompt the user for the path to the spreadsheet.
The name of the spreadsheet ("worksheet 1" for this example) will stay the
same. Only the path will change. How can I do this?
 
G

Guest

Here is an example from one of my apps:

Do While True
strGetFileName = ahtCommonFileOpenSave(ahtOFN_OVERWRITEPROMPT, , _
"Excel Spreadsheets (*.xls) *.xls", , _
"xls", , "Create Spreadsheet", , False)
If strGetFileName = "" Then
If MsgBox("Cancel Export?", vbQuestion + vbYesNo, "Export
Spreadsheet") _
= vbYes Then
Exit Function
End If
Else
Exit Do
End If
Loop

DoCmd.TransferSpreadsheet acExport, , "tblDeptTopPct", _
strGetFileName, True

Call Shell("Excel " & Chr$(34) & strGetFileName & Chr$(34),
vbMaximizedFocus)
 
G

Guest

Thank you but I don't want to create a new Excel spreadsheet. I want to Open
an existing spreadsheet. How do I do this, using the code you provided?
 
R

Ron2006

If you have the file name, which I assume you do then you can do the
following:

application.followhyperlink "fullyqualifiedexcellfilename"

Ron
 
R

Ron2006

If you have the file name, which I assume you do then you can do the
following:

application.followhyperlink "fullyqualifiedexcellfilename"

Ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top