Opening Excel file from Access button

durdle

Registered User.
Local time
Today, 07:55
Joined
May 7, 2002
Messages
130
Hey,

I should know this, matter of fact I may have posted this same question a couple of months back. I need to open an excel file from a command button but I am getting the user-type not defined error message.

Private Sub Command12_Click()
Dim appXL As Excel.Application


Set appXL = CreateObject("Excel.Application")

appXL.Workbooks.Open ("K:\Todayis\Friday\JustaFewmorehours.xls ")

End Sub

Any help would be great.

durdle
________
v
 
Last edited:
Hi Durdle,

This code does the same, but quicker:
Code:
Private Sub Command12_Click()
  FollowHyperlink "K:\Todayis\Friday\JustaFewmorehours.xls"
End Sub
 
Thanks SforSoftware worked great.
________
launch box
 
Last edited:
I knew :D

Glad to help you

Maybe interesting for other moments that you've to work between Access and Excel:

Use CreateObject only when you declare xlApp As Object. Now you declared it as Excel.Application, so you've to set it as follows:
Set xlApp = New Excel.Application

Or:
Dim xlApp As New Excel.Application
and you don't need a Set-statement.

Greetz,
Bert
 
Last edited:
Dave,

I looked at it. It works in that way, but I attached a modified version and I'll think this works quicker, because you don't have to create an ExcelObject

Greetz,
Bert
 

Attachments

Users who are viewing this thread

Back
Top Bottom