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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OPEN EXCEL FILE FROM ACCESS

Status
Not open for further replies.

fusion007

Technical User
May 10, 2007
12
GB
Hi...
I'm trying to use a command button to open a excel file saved on a local directory.
I can get it to open the Excel application with this code:

Private Sub xlapp_Click()
Dim stAppName As String

stAppName = "C:\Program Files\Microsoft Office\OFFICE11\excel.exe"
Call Shell(stAppName, 1)


Exit_xlapp_Click:
Exit Function


End Function

But I don't know what code I need to open the required file once the application is open.

Can someone please help? Thanks
 
Hi..
Try this under a command button...


Dim objXLApp As Object
Dim objXLBook As Object
Set objXLApp = CreateObject("Excel.Application")
Set objXLBook = objXLApp.Workbooks.Open("Path to excel Document.xls")
objXLApp.Application.Visible = True
 
It is also possible to use FollowHyperlink to open a file with the registered programme:

[tt]FollowHyperlink "Path to excel Document.xls"[/tt]
 
Thanks Remou...that works well as well. I also tried this code to open microsoft outlook, it works but a message is displayed "are you sure you want to open......" before Outlook opens.

What I'm trying to do is have a access form as a front end on my desktop so that I can open applciations and files just by clicking a command button.
Is there a way I can set the access database to open automatically as soon as I log into the PC?
(Sorry if this is not the right place for this question)
 
Yes, you can put it in StartUp, if you are on XP you will find it here:

[tt]C:\Documents and Settings\UserName\Start Menu\Programs\Startup[/tt]

Or by right-clicking on StartUp on the program menu and choosing Open.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top