Open Excel File

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?
 
N

nathan harrison

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
 
G

Guest

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




.
 
A

Annelie

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
 

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