ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Determining how excel was started (https://www.excelbanter.com/excel-programming/340903-determining-how-excel-started.html)

Gilgamesh[_3_]

Determining how excel was started
 
I have an Auto_Open macro in a file in the XLStart directory that I want to
behave differently if Excel is launched just by running the .exe or by
double clicking on an .xls file.
There has been a suggestion of checking for the book1.xls file but because I
have files in the XLStart directory the book1.xls file does not get created
when excel is launched.

Is there any way of telling programatically how excel of started? In my old
unix days we could examine the parameter lines into the programe.

Thanks



Gilgamesh[_3_]

Determining how excel was started
 
"Gilgamesh" wrote in message
...
I have an Auto_Open macro in a file in the XLStart directory that I want to
behave differently if Excel is launched just by running the .exe or by
double clicking on an .xls file.
There has been a suggestion of checking for the book1.xls file but because
I have files in the XLStart directory the book1.xls file does not get
created when excel is launched.

Is there any way of telling programatically how excel of started? In my
old unix days we could examine the parameter lines into the programe.

Thanks


I should have mentioned I'm using Excel 2003





Helmut Weber[_2_]

Determining how excel was started
 
Hi,

maybe this is a silly idea,
as I am just trying to get to grips with Excel.

If Excel was not started by double clicking on a file,
then only the Workbooks in the XLStart-folder are loaded.
To me it seems, they are loaded in alphabetical order.

So if your auto_open macro is in the last of the loaded
files, simply check whether the number of open workbooks
equals the number of Excel-files in XLStart.
If so, Excel was not started by double clicking on a file.

If you auto_open macro is not in the last file to be loaded,
then you could use application.ontime and wait some seconds,
til all files from XLStart are loaded. Like this:

Sub auto_open()
Application.OnTime Now + TimeValue("00:00:05"), "Checkbook"
End Sub

Sub checkbook()
If Workbooks.Count 3 Then
MsgBox "Excel was started with file"
Else
MsgBox "Excel was started without file"
End If
End Sub

Not a very safe approach, though.

--
Greetings from Bavaria, Germany

Helmut Weber

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"



NickHK

Determining how excel was started
 
Gilgamesh,
There are ways to read Excel's Command line arguments. Not sure what it
would give you, but may include a filename if .xls file is clicked.
Can't find a link, but I have seen such.
Try a Google.

NickHK

"Gilgamesh" wrote in message
...
I have an Auto_Open macro in a file in the XLStart directory that I want

to
behave differently if Excel is launched just by running the .exe or by
double clicking on an .xls file.
There has been a suggestion of checking for the book1.xls file but because

I
have files in the XLStart directory the book1.xls file does not get

created
when excel is launched.

Is there any way of telling programatically how excel of started? In my

old
unix days we could examine the parameter lines into the programe.

Thanks






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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com