Determine hoe excel was launched

T

Tim Marsden

Hi,

How do I determine if excel was launch by double clicking a workbook, or by
running the excel.exe.
I need this info within my vb.net com addin.

Thanks
 
P

Peter Huang [MSFT]

Hi Tim,

Thanks for your posting!

From your description, I understand that you want to tell if the Excel is
lauched by double click a xls file or type Excel.exe to execute it directly
from within the Excel Com Addin.

Have I fully understood you? If there is anything I misunderstood, please
feel free to let me know.

Based on my research, so far from the Addin method, it did not provide such
a parameter to tell from the two behavior.
Public Sub OnConnection(ByVal application As Object, ByVal connectMode As
Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As
System.Array) Implements Extensibility.IDTExtensibility2.OnConnection

The last parameter custom will only tell if the Excel is lauched by any of
the three possibility.
1. By User(double click xls or run excel.exe)
2. By OLE( open an xls file in IE or other activex document container)
3. By Automation(Use Code,e.g CreateObject to launch Excel)

But for the two scenarios you care, it will always return 1 means, By User.

So why you need to detect that? Maybe there is a workaround.

Based on my research, for the two scenario the code below may differ.
applicationObject.ActiveWorkBook.Path.ToString()

If we launch Excel.exe, it will open a blank workbook, and now the Path is
empty because we have not saved it.

If we double click a xls file, the Path will be the path to the physical
path of the xls.

So that may give you some hint.

But the method have many limitations, if we call it too early, the
ActiveWorkBook is empty.

You may have a try according to your concrete scenario, if you still have
any concern, please feel free to post here.

Thanks!

Best regards,

Peter Huang

Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| Thread-Topic: Determine hoe excel was launched
| thread-index: AcaV82R9Re48ytaQQNG6oOWQ3OESIA==
| X-WBNR-Posting-Host: 88.110.52.57
| From: =?Utf-8?B?VGltIE1hcnNkZW4=?= <[email protected]>
| Subject: Determine hoe excel was launched
| Date: Thu, 22 Jun 2006 05:00:02 -0700
| Lines: 10
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| Newsgroups: microsoft.public.office.developer.com.add_ins
| Path: TK2MSFTNGXA01.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.office.developer.com.add_ins:11459
| NNTP-Posting-Host: TK2MSFTNGXA01.phx.gbl 10.40.2.250
| X-Tomcat-NG: microsoft.public.office.developer.com.add_ins
|
| Hi,
|
| How do I determine if excel was launch by double clicking a workbook, or
by
| running the excel.exe.
| I need this info within my vb.net com addin.
|
| Thanks
|
| --
| Tim Marsden
|
 

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