Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open MS Excel workbook 1

Status
Not open for further replies.

KatGraham

Programmer
Feb 12, 2003
58
US
How do I open a MS Excel workbook from Access?
 
1) with a macro:
RunApplication
Application Name= "C:\Program Files\Microsoft Office\Office\Excel.exe" "c:\folder\myworkbook.xls"

2) with code:
e.g.
AppActivate Shell("C:\Program Files\Microsoft Office\Office\Excel.exe " & chr(34) & "c:\folder\myworkbook.xls" & chr(34),vbmaximizedfocus),1

Hope this helps,
MakeItSo

Andreas Galambos
EDP / Technical Support Specialist
(andreas.galambos@bowneglobal.de)
HP:
 
What do you mean with "too long"?
Too long for the line in a macro?

BTW: ggriffit has a good point here:
If you want to exchange data to/from an Excel Sheet, the TransferSpreadsheet method would be the best way.
Help file (F1) should give you good examples on how to apply the syntax for your case.

If you just want to open the spreadsheet,
create a button on the form from which you want to open it, display its properties,
go to the "Events" tab,
in the Line "OnClick" click on the three dots to the right,
paste this between Private Sub... and End Sub:

AppActivate Shell("C:\Program Files\Microsoft Office\" & _
Office\Excel.exe " & chr(34) & _
"c:\folder\myworkbook.xls" & chr(34),vbmaximizedfocus),1

Adapt the Path to Excel and to your file, voilà.
 
I have tried this but I get an error message.

What is chr(34)?
 
a) Chr(34) is the VB-Code for the double-quote "
b) what kind of error message - there are so many ;-)
 
In code behind a button, I put the following:

AppActivate Shell("C:\Program Files\Microsoft Office\Office10\EXCEL.EXE" & Chr(34) & "\\LX-file-ABC-01\central\Corporate\Group-Markets-2\Svc1Vol8\Reports\AdHoc\XXXXX\Req1358-XXXXX-Weekly\Completed Reports\10.30.2003-XXXXX-Weekly.xls" & Chr(34), vbMaximizedFocus), 1

I get error message:

Run-time error '53'
File not found

If I put:
stAppName = "Excel.exe \\LX-file-ABC-01\central\Corporate\Group-Markets-2\Svc1Vol8\Reports\AdHoc\XXXXX\Req1358-XXXXX-Weekly\Completed Reports\10.30.2003-XXXXX-Weekly.xls"
Call Shell(stAppName, 1)

I get an error message BUT if I copy the xls file closer in the path it works (which makes me believe that the path name is too long).

Help?
 
Ah yeah! ;-)
There's a space missing behind "Excel.exe ":
AppActivate Shell("C:\Program Files\Microsoft Office\Office10\EXCEL.EXE " & Chr(34) & "\\LX-file-ABC-01\central\Corporate\Group-Markets-2\Svc1Vol8\Reports\AdHoc\XXXXX\Req1358-XXXXX-Weekly\Completed Reports\10.30.2003-XXXXX-Weekly.xls" & Chr(34), vbMaximizedFocus), 1

The application path and that to the file must be separated by a space.
BTW: your path is long indeed, but it should work anyway.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top