D
Daniel Kim
I've been writing software to automate Word for more than a year now using
Visual Studio, C++, and I've just recently run into a seeming bug... I
don't think this "bug" (if it's a bug) is C++ specific, so if you are using
other languages, you can still help... I am using msword9.olb type library
to automate it.
The problem is this: Even though I create a brand new document using word
automation, calling Section.GetHeaders() always seems to return headers!
Even though there are none.
In order to find out if this header is empty, I have to get the Range
Property on the HeaderFooter object by calling GetRange()... and this seems
to actually create the header (which then pushes down the text that happens
to be in the header margins). In effect, it seems that Word automation
creates blank headers simply by probing for a header.
Most of the time, this is unnoticed by the user, because the top margins are
usually 0.5" or more. But my customers first noticed the problem when they
set the top margin to 0.3" or less, and then when I automate Word, it
creates a blank header, thus pushing down the text.
My question is:
Is this a bug in MS Word automation library? Why would GetHeaders() always
return something rather than nothing? Is there any way to detect an empty
header and delete it?
By the way, I tried to get the Text property from the Range (gotten from the
HeaderFooter object) to see if it's empty, but because there's a return
character, my effort to see if the Text property returns a null also fails.
Any help would be greatly appreciated. Anyone who has run into this problem
before?
--Daniel
Visual Studio, C++, and I've just recently run into a seeming bug... I
don't think this "bug" (if it's a bug) is C++ specific, so if you are using
other languages, you can still help... I am using msword9.olb type library
to automate it.
The problem is this: Even though I create a brand new document using word
automation, calling Section.GetHeaders() always seems to return headers!
Even though there are none.
In order to find out if this header is empty, I have to get the Range
Property on the HeaderFooter object by calling GetRange()... and this seems
to actually create the header (which then pushes down the text that happens
to be in the header margins). In effect, it seems that Word automation
creates blank headers simply by probing for a header.
Most of the time, this is unnoticed by the user, because the top margins are
usually 0.5" or more. But my customers first noticed the problem when they
set the top margin to 0.3" or less, and then when I automate Word, it
creates a blank header, thus pushing down the text.
My question is:
Is this a bug in MS Word automation library? Why would GetHeaders() always
return something rather than nothing? Is there any way to detect an empty
header and delete it?
By the way, I tried to get the Text property from the Range (gotten from the
HeaderFooter object) to see if it's empty, but because there's a return
character, my effort to see if the Text property returns a null also fails.
Any help would be greatly appreciated. Anyone who has run into this problem
before?
--Daniel