Opening an Excel file from a Userform

A

assertec

Hi all,

I need some code that will allow me to open an Excel Workbook from a
command button I have placed on my Userform.

My Userform form has various command buttons that allow me to open Word
documents, and I need the equivalent that will allow me to now open
Excel files as well.

This is an example of the code that sits under a command button that
will allow me to open a Word document.

Private Sub cmdShowDocument1_Click()
Call OpenFile("C:\Document1.doc")
End Sub

.... and this is the called function.

Public Sub OpenFile(ByVal File_Name As String)
Dim OpenFileVar
OpenFileVar = ShellExecute(0&, "open", File_Name, vbNullString,
vbNullString, 1)
End Sub

I need something similar that will allow me to open Excel Workbooks.

Thanks very much for your help with this.

Regards
Karen
 
J

Jim Cone

Karen,

Assuming you are running your code from Excel then...
Workbooks.Open "FilePath\FileName.xls"

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


Hi all,
I need some code that will allow me to open an Excel Workbook from a
command button I have placed on my Userform.
My Userform form has various command buttons that allow me to open Word
documents, and I need the equivalent that will allow me to now open
Excel files as well.
This is an example of the code that sits under a command button that
will allow me to open a Word document.

Private Sub cmdShowDocument1_Click()
Call OpenFile("C:\Document1.doc")
End Sub

.... and this is the called function.

Public Sub OpenFile(ByVal File_Name As String)
Dim OpenFileVar
OpenFileVar = ShellExecute(0&, "open", File_Name, vbNullString,
vbNullString, 1)
End Sub

I need something similar that will allow me to open Excel Workbooks.
Thanks very much for your help with this.
Regards
Karen
 

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