Using VBA to set "Disable features introduced after" to false.

S

Sharat Koya

Hi I have tried to use the following line of code to disable the feature
"Save Word files as" option in Word options on document open:

Word.Options.DisableFeaturesbyDefault = False

by using this I was hoping to disable stop the option from renabling with
older documents also.

I also added the following line :
Me.DisableFeatures = False

However when I launch the document the Compatibility Option "Don't use HTML
paragraph auto spacing" is checked which alters the location of some of word
content.
 
J

Jay Freedman

The disabled-features items have little or nothing to do with the
compatibility options. The code you want for this is

ActiveDocument.Compatibility(wdDontUseHTMLParagraphAutoSpacing) =
False

This statement has to run after the document in question has been
opened. If you save the document after that, the option will be saved
in the document's file; you wouldn't have to set it again, although it
won't do any harm to do so.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
S

Sharat Koya

For sure, but how can I disable the "disable features introduced after"
option without enabling "Don't use HTML paragraph auto spacing" or do I have
to disable both - one after another?
 
J

Jay Freedman

It looks like you'll have to do both. This works here (Word 2003):

Options.DisableFeaturesbyDefault = False
With ActiveDocument
.DisableFeatures = False
.Compatibility(wdDontUseHTMLParagraphAutoSpacing) = False
End With

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
S

Sharat Koya

Ok that works great in the VBA when the document is open. I am also
attempting to disable the feature before my document gets launched from C#
using Interop.

I can sucessfully create the document:
-Microsoft.Office.Interop.Word.Document doc = word.Document.Open(ref
wordFilePath, ...... );

I then check to see if "Disable features introduced after" is enabled and
disable it:
-if (word.Options.DisableFeaturesbyDefault)
- {
- doc.DisableFeatures = false;
- word.Options.DisableFeaturesbyDefault = false;
- doc = null;
-}


I then open the document where I don't want "Disable features introduced
after" enabled:

-doc = word.Documents.Open(ref wordFilePath, ...);

I then use the doc.SaveAs command to save as a word document as the original
was a template:
-object docFormat = WdSaveFormat.wdFormatDocument;
-doc.SaveAs(ref wordFilePath, ref docFormat, ref missing ...);

When I trace through this code both
word.Options.DisableFeaturesbyDefault and doc.DisableFeatures are false.
As soon as the document is saved using doc.SaveAs doc.DisableFeatures gets
set to true and any subsequent document has the "Disable Features introduced
after" enabled. Should this happen when using the SaveAs features.

I am guessing that the SaveAs method retrieves older settings from the
registry under
\\HK Current User\Software\Microsoft\Office\11.0\Word\Data

Is there any way of permanently disabling this feature from C# Interop?

thanks for any time spent on this,
 
J

Jay Freedman

Sorry, I don't have any experience with C# interop or any way to test
this. The best I can suggest is to move the discussion over to the
microsoft.public.word.programming newsgroup
(http://www.microsoft.com/communitie...ult.aspx?dg=microsoft.public.word.programming)
where you'll find more people with experience in .Net and VSTO.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

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