Open Excel File

  • Thread starter Thread starter Btrian
  • Start date Start date
B

Btrian

I would like to insert a command button that, when
clicked, allows for a specific Excel file to open. What
is the best way to do this?
 
Hi,

you can put this behind a command button.
'****begin****
Dim objXL As Object

Set objXL = CreateObject("Excel.Application")
objXL.Visible = True
objXL.Workbooks.Open ("c:\temp\lisa.xls") <---location of the Excel file

Set objXL = Nothing
'***end*****
also, be sure to set a reference to Excel in your VBA References. In the
VBA window, Goto: Tools>References. look for Microsoft Excel Objects and
check it if it not already check.

HTH
 
Nathan,
Thanks for the tip. It works great!
-----Original Message-----
Hi,

you can put this behind a command button.
'****begin****
Dim objXL As Object

Set objXL = CreateObject("Excel.Application")
objXL.Visible = True
objXL.Workbooks.Open ("c:\temp\lisa.xls") <--- location of the Excel file

Set objXL = Nothing
'***end*****
also, be sure to set a reference to Excel in your VBA References. In the
VBA window, Goto: Tools>References. look for Microsoft Excel Objects and
check it if it not already check.

HTH
--
Thanks,
Nathan H.
Senior Test Manager
www.skylineprints.com




.
 
Building on that thought I can now open the file where I want to extract
data from. How can I go and copy that data into an existing table?
Annelie
 
Back
Top