Jay
Tue Apr 17 19:35:21 CDT 2007
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/communities/newsgroups/list/en-us/default.aspx?dg=microsoft.public.word.programming)
where you'll find more people with experience in .Net and VSTO.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ:
http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
On Tue, 17 Apr 2007 06:18:02 -0700, Sharat Koya
<SharatKoya@discussions.microsoft.com> wrote:
>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,
>
>"Jay Freedman" wrote:
>
>> 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 FAQ:
http://word.mvps.org
>> Email cannot be acknowledged; please post all follow-ups to the newsgroup so
>> all may benefit.
>>
>> Sharat Koya wrote:
>> > 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?
>> >
>> > "Jay Freedman" wrote:
>> >
>> >> 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 FAQ:
http://word.mvps.org
>> >> Email cannot be acknowledged; please post all follow-ups to the
>> >> newsgroup so all may benefit.
>> >>
>> >> On Mon, 16 Apr 2007 04:44:02 -0700, Sharat Koya
>> >> <SharatKoya@discussions.microsoft.com> wrote:
>> >>
>> >>> 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.
>>
>>
>>