For Programmers: Free Programming Magazines  


Home > Archive > Delphi > January 2006 > Accessing MS Word Header









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Accessing MS Word Header
Will

2006-01-10, 4:12 am

I have found a few posts about this but none of them seem to work. I am
trying to access the header row from a MS Word 2003 document. I can
open Word, but not access the header. I am using the following code:

var
MSWord, Table, Header: OLEVariant;
Begin
MSWord := CreateOleObject('Word.Application');

if OpenDialog1.Execute then
AWordDoc := OpenDialog1.FileName;

try
MSWord.Visible := False;
MSWord.Documents.Open(AWordDoc);

//Get the header information
Header :=
MSWord.ActiveDocument.Sections.Item(1).Headers.Item('wdHeaderFooterPrimary');

I am receiving the error Type Mismatch. Other posts discussed defining
the Header variable as type HeaderFooter, but that gives me an error
too. Am I missing something in the uses section?

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com