Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Opening an Excel file from a Userform

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Opening an Excel file from a Userform

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


wrote in message...
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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
opening a file in Excel starts application but dose not open file Bob Shelton Excel Discussion (Misc queries) 1 July 2nd 08 07:51 PM
Opening file in Excel 2003 opens multipule instances of same file Ed_B Excel Discussion (Misc queries) 1 June 21st 07 07:10 PM
opening an excel file opens a duplicate file of the same file skm Excel Discussion (Misc queries) 1 December 7th 05 05:52 PM
Error:Invalid File format,while opening an Excel Template file Saurabh Excel Programming 1 January 17th 05 07:15 AM
Excel VBA question - showing userform when opening workbook ajliaks Excel Programming 2 April 12th 04 06:24 PM


All times are GMT +1. The time now is 07:55 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"