Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7
Default Command-line switches

I'm trying to call an Excel file from Access VBA using the Shell command. I
want to be able to select one of two worksheets to be activated whenever I
make the call. One shows a monthly chart and the other a quarterly chart.

Is there a command-line switch that I can use when calling Excel.exe that
will activate the worksheet of my choice?

Thanks,
TJ Dowling

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Command-line switches

There are no commandline switches that will do this.

In fact, if you're using the Shell command, I'm not sure you can do it at all.

But you could use something like this instead:

Option Explicit
Sub testme()

Dim XLApp As Object
Dim XLWkbk As Object
Dim wkbkName As String
Dim XLWasRunning As Boolean

wkbkName = "C:\my documents\excel\book1.xls"

XLWasRunning = True
On Error Resume Next
Set XLApp = GetObject(, "Excel.Application")
If Err.Number < 0 Then
Set XLApp = CreateObject("Excel.Application")
XLWasRunning = False
End If

XLApp.Visible = True 'at least for testing!

Set XLWkbk = XLApp.workbooks.Open(FileName:=wkbkName)

'this line will change depening on the sheet to select
XLApp.GoTo XLWkbk.worksheets("Sheet2").Range("a1")

Set XLWkbk = Nothing
Set XLApp = Nothing

End Sub

TJ Dowling wrote:

I'm trying to call an Excel file from Access VBA using the Shell command. I
want to be able to select one of two worksheets to be activated whenever I
make the call. One shows a monthly chart and the other a quarterly chart.

Is there a command-line switch that I can use when calling Excel.exe that
will activate the worksheet of my choice?

Thanks,
TJ Dowling


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Command-line switches

ps. I didn't test this in access--but it did work ok in MSWord.

Dave Peterson wrote:

There are no commandline switches that will do this.

In fact, if you're using the Shell command, I'm not sure you can do it at all.

But you could use something like this instead:

Option Explicit
Sub testme()

Dim XLApp As Object
Dim XLWkbk As Object
Dim wkbkName As String
Dim XLWasRunning As Boolean

wkbkName = "C:\my documents\excel\book1.xls"

XLWasRunning = True
On Error Resume Next
Set XLApp = GetObject(, "Excel.Application")
If Err.Number < 0 Then
Set XLApp = CreateObject("Excel.Application")
XLWasRunning = False
End If

XLApp.Visible = True 'at least for testing!

Set XLWkbk = XLApp.workbooks.Open(FileName:=wkbkName)

'this line will change depening on the sheet to select
XLApp.GoTo XLWkbk.worksheets("Sheet2").Range("a1")

Set XLWkbk = Nothing
Set XLApp = Nothing

End Sub

TJ Dowling wrote:

I'm trying to call an Excel file from Access VBA using the Shell command. I
want to be able to select one of two worksheets to be activated whenever I
make the call. One shows a monthly chart and the other a quarterly chart.

Is there a command-line switch that I can use when calling Excel.exe that
will activate the worksheet of my choice?

Thanks,
TJ Dowling


--

Dave Peterson


--

Dave Peterson
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
Command line switches - possible T1 Red Alarm Excel Discussion (Misc queries) 2 August 19th 07 08:54 AM
Command line switches - possible Niniel Excel Discussion (Misc queries) 0 August 17th 07 01:53 AM
Command line switches - possible Duke Carey Excel Discussion (Misc queries) 0 August 17th 07 01:44 AM
Command Line Export fjurek Excel Discussion (Misc queries) 6 April 23rd 07 09:08 PM
Q: command line in OE JIM.H. Excel Discussion (Misc queries) 0 May 30th 05 10:48 PM


All times are GMT +1. The time now is 10:10 AM.

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"