Adithyakiran.k has asked for the wisdom of the Perl Monks concerning the following question:

I am using win32::ole to create a word document from an xml. I have to Format the text with in the footnotes based on the tags. The below code is adding the text with the "i" tags to the Footnote text.

Is there anyway to format the footnote text that is added to the Word doc?

#---------------------------------------- #Insert Footnote Here $selection->Move(-1); $selection->Footnotes->Add( $selection->{Range},"1", "This is the <i>F +irst Footnote</i>"); $selection->Move(1);

The text within the "i" tags (i.e.,. First Footnote) should be in Italics Format in Footnote in word document.

Replies are listed 'Best First'.
Re: Formatting the text while adding the footnote in MS Word
by dasgar (Priest) on Nov 12, 2013 at 06:26 UTC

    The short answer: yes

    When you use the Win32::OLE module to drive Word, you can just about do anything via Perl code that you can do when manually using Word with a mouse and keyboard. The main trick to learn when using Win32::OLE and Microsoft Office products is to try the task manually and record it as a macros. Then look at the source code of that macros, which will be in VB (or VBscript, which has very similar syntax). Then you just need to convert that into Perl syntax. If you do a search, you'll find other nodes with more details on using macros to help figure out code using Win32::OLE.

    Unfortunately, I'm more familiar with using Win32::OLE with Excel and I would need to use the macros trick myself to offer you more concrete code that does what you're looking for. This information should hopefully help point you in the right direction.