Error message "This method or property is not available because...

S

Sunny Kang

Hi all,

I'm trying to handle a footer of Word documents with VS 2005 and MS Wrod 2003.
The code is the following.

oApp = New Microsoft.Office.Interop.Word.Application
oDoc = oApp.Documents.Open(szFileFullPath)
nSecCount = oDoc.Sections.Count
For i = 1 To nSecCount
If oDoc.Sections(i).PageSetup.DifferentFirstPageHeaderFooter = True Then
'Do something
End If
Next

The above code works for most of my Word document.
But a few document makes the following error message.
"This method or property is not available because the object refers to a
framed paragraph."
"If oDoc.Sections(i).PageSetup.DifferentFirstPageHeaderFooter = True Then"
line makes the above error message.
Thanks for any comments.
 
C

Cindy M.

Hi Sunny,

Mmmm. My best guess would be that the first/only character in the section being
addressed contains an anchor to a Frame or to a (drawing tool) Textbox. Word's
Insert/Page Number tool creates the page number in such a text box. Could you
check exactly what's in the headers/footers of the document section that causes
this error?
I'm trying to handle a footer of Word documents with VS 2005 and MS Wrod 2003.
The code is the following.

oApp = New Microsoft.Office.Interop.Word.Application
oDoc = oApp.Documents.Open(szFileFullPath)
nSecCount = oDoc.Sections.Count
For i = 1 To nSecCount
If oDoc.Sections(i).PageSetup.DifferentFirstPageHeaderFooter = True Then
'Do something
End If
Next

The above code works for most of my Word document.
But a few document makes the following error message.
"This method or property is not available because the object refers to a
framed paragraph."
"If oDoc.Sections(i).PageSetup.DifferentFirstPageHeaderFooter = True Then"
line makes the above error message.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 

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