Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl script to turn off MS Word Track Changes balloons

Status
Not open for further replies.

RustyJ

Programmer
Apr 10, 2008
1
US
Hi,
I am a beginner with Perl. I have a perl script which converts MS Word documents to PDF using activepdf. In perl script, before sending a file for conversion to activepdf, i want to turn off MS Word's track changes balloons so that the document which i send for conversion will be stripped off any track changes balloons if there are any.
Any help or advice will be highly appreciated.
Thanks and Regards,
Rusty
 
Hi

The easiest way to do it is opening a word doc, recording a macro and desactivating "Track Changes options". Then convert VBA Word code to OLE.

See vba code

Code:
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 4/10/2008 by dmazzini'
    ActiveDocument.TrackRevisions = Not ActiveDocument.TrackRevisions
    ActiveDocument.SaveAs FileName:="MyfileDocument.doc", _
        FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _
        AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
        EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
        :=False, SaveAsAOCELetter:=False
End Sub

perl code would be something like this:

Code:
use Win32::OLE;
use constant wdFormatDocument => 0;

my $_app_object = (Win32::OLE->GetActiveObject('Word.Application') ||
                   Win32::OLE->new('Word.Application'));

$_app_object->ActiveDocument->{TrackRevisions} = !$_app_object->ActiveDocument->TrackRevisions;
$_app_object->ActiveDocument->SaveAs({FileName => MyfileDocument.doc', FileFormat => wdFormatDocument, LockComments => 0, Password => '', AddToRecentFiles => 1, WritePassword => '', ReadOnlyRecommended => 0, EmbedTrueTypeFonts => 0, SaveNativePictureFormat => 0, SaveFormsData => 0, SaveAsAOCELetter => 0});

I have not tested it...





dmazzini
GSM/UMTS System and Telecomm Consultant

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top