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

Calling a specific Excel worksheet from Access

Status
Not open for further replies.

Joshua61679

Technical User
Dec 28, 2001
36
US
I'm kind of new to VBA programming. I've been using Access for about a year, but have avoided VBA 'till now. I'm in Access trying to call up an Excel worksheet named "simplecasedhole.xls" in the c:\ directory when a command button is clicked. This is the code I'm using:

Private Sub Done_Click(Path As String)

Dim xlApp As Excel.Application

If Dir(Path) = "" Then
MsgBox Path & " isn't a valid path!"
Exit Sub
Else
Set xlApp = CreateObject("Excel.Application")

xlApp.Visible = True
xlApp.Workbooks.Open "C:\simplecasedhole.xls"
End If

End Sub

Its not working though. Any ideas as to what I'm doing wrong?
 
Your code works in Access 2000. Are you getting a compile error on your DIM statement? If that is the case then you need to set the Excel library as a reference. In VBA go to Tools => References and check "Microsoft Excel [8/9/10].0 Object Library".
 
I'm using Access 2002. The error message I'm getting is:

The expression On Click you entered as the event property setting produced the following error: Procedure declaration does not match description of event or procedure having the same name.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top