Running Excel from Command Button

J

Jim Pockmire

I created a button on a form to open Excel using the wizard. How do I
specify Excel to open a particular path/file much like I would with a
command line argument? The wizard code is below, or do I need something
different?

Private Sub RunExcel_Click()
On Error GoTo Err_RunExcel_Click

Dim oApp As Object

Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
'Only XL 97 supports UserControl Property
On Error Resume Next
oApp.UserControl = True

Exit_RunExcel_Click:
Exit Sub

Err_RunExcel_Click:
MsgBox Err.Description
Resume Exit_RunExcel_Click

End Sub
 
T

Tony C

Rather than using the code you have submitted, try
using "Shell": -

stAppName = "C:\Program Files\Microsoft
Office\Office\WINWORD.EXE \\ESE_Server\esenotes\6400
\023_Fieldbus_Library_Report.doc"
Call Shell(stAppName, 1)

Not that the "stAppName" is a two-part declaration, with a
space seperating the declarations between the Application
called and the document that will be opened.

HTH


Tony C.
 

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