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 6378615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:01:51+00:00 2026-05-25T02:01:51+00:00

Using Word Automation, I want to save the active document programmatically. In Office 2007/2010,

  • 0

Using Word Automation, I want to save the active document programmatically. In Office 2007/2010, the document needs to be saved explicitly as “macro enabled” to preserve any VBA code in that document.

Rather than asking the user to choose, I would like my application to be able to determine if there is VBA code in the active document. Is that possible?

  • 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-25T02:01:52+00:00Added an answer on May 25, 2026 at 2:01 am

    Yes this can be determined via the HasVBProject property. For example:

    If ActiveDocument.HasVBProject = True Then
    
        'Code to save as .dotm
    
    Else
    
        'Code to save as .dotx
    
    End If
    

    For those who might stumble upon this post later, it is worth noting that this code should be placed outside the document being tested for the presence of macros (otherwise it would detect itself). Two often-used options would be to access the code from an external application or from a template stored in Word’s Startup folder.

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

Sidebar

Related Questions

I am trying to using Word Automation to save a document to a network
I am programmatically generating Office Documents (in my case Word or Excel 2007) using
I'm considering using the Word Automation Services feature of SharePoint 2010 for a project.
I'm using automation to update protected fill-in form fields in a word document created
I'm using C# office ( word ) automation by Microsoft Office 12.0 Object Library
I am currently in the process of creating API documentation using Microsoft Word 2007
I'm trying to add some HTML formatted text to Word using Office Interop. My
I am using Word Automation to manipulate some documents (yuk!). I am using this
I am writing a converter from XML&MathML to MS Word document. I'm using MFC
I am using the following code to print a word document from a C#

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.