Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5955501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:07:24+00:00 2026-05-22T18:07:24+00:00

I have some code in an Office VSTO addin (implemented for Word, Excel 2003

  • 0

I have some code in an Office VSTO addin (implemented for Word, Excel 2003 & 2007 in VB.NET) that is causing problems for some external automation code.

Is there a way I can determine whether an Office document has been opened by automation code, versus opened by a user? Some difference in the Application or Document objects, or an event I can handle that only fires in one or the other circumstance?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:07:25+00:00Added an answer on May 22, 2026 at 6:07 pm

    Ok, so when an Office application is opened through the Office Object Model, the command line uses the /automation switch (eg. Winword.exe /automation).

    So I’m just checking for this in the startup of my addin and setting a global Boolean:

    If (Environment.CommandLine.IndexOf("/automation", StringComparison.OrdinalIgnoreCase) >= 0) Then mbOpenedByAutomation = True
    

    I’ve got to do some testing to make sure there aren’t any other situations which might use that switch, but I think this will do the trick.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have code that worked in the VSTO version of an Excel Addin Microsoft.Office.Tools.Excel.ListObject
I have written some VSTO (2003) code that sucessfully applies some mandatory subject line
I have some C# automation code which does interesting things with Microsoft.Office.Interop.Word.Document objects. The
I have a problem with some excel code that I am having trouble getting
Interop.Excel version 12 Office Excel 2007 I have worked on code to open .xslm
I have some code for starting a thread on the .NET CF 2.0: ThreadStart
I have some code in a javascript file that needs to send queries back
I have some code that gives a user id to a utility that then
So i have an image on my computer that has office 2007, and I
I have some c# code running on sharepoint that i use to check inside

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.