Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

starting Excel from Access

Status
Not open for further replies.

JeroenNL

Programmer
Nov 28, 2002
217
NL
Hi there,

Inside an Access macro, I start Excel with this line:

d:\blabla\excel.exe "e:\blabla\myworkbook.xls"

The workbook contains various worksheets. I want to be able to show one of these sheets when the workbook is opened. I thought about writing macros in the Excel workbook and call them from the commandline like this:

d:\blabla\excel.exe "e:\blabla\myworkbook.xls /m mymacro"

But this doesn't seem to work. How can I achieve what I want?

Bye,
Jeroen

A 3d level editor in Delphi
 
Hi,

You need to have a reference set to the Excel Object Library (Tools/References) AND you need to create an Excel Object in your code using CreateObject.
Code:
Dim xlApp As Object    ' Declare variable to hold the reference.
    
Set xlApp = CreateObject("excel.application")
    ' You may have to set Visible property to True
    ' if you want to see the application.
xlApp.Visible = True
    ' Use xlApp to access Microsoft Excel's 
    ' other objects.
xlApp.Quit    ' When you finish, use the Quit method to close 
Set xlApp = Nothing    ' the application, then release the reference.
Hope this helps :)

Skip,
Skip@TheOfficeExperts.com
 
Thanks Skip. I found a simular answer in another thread I posted. It's thread181-596309. The solution goes just a little futher than your code here. But thanks again.

Bye,
Jeroen

A 3d level editor in Delphi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top