Graphic in the header corrupts the page numbering in the section

W

Where am I?

Hello,
I have a (Word 2002) document with 100 plus sections in it. The layout of
the sections alternates between landscape and portrait.

I add in an icon to the headers programmatically using VB (different icon
dependant on the content of each section). This works fine. When I do this
the page numbers in each of the sections gets corrupted. I know this as if I
remove the last paragraph mark the text is fixed. I am using {PAGE} of
{NUMPAGES} in the footer to show the page number. The {NUMPAGES} field is
correctly calculated the {PAGE} is shown as 0 for each section when I add in
the icon into header.

I have read about the X of Y errors in the MVP html pages and the solutions
there do not resolve the problem so please do not direct me there.

Apparently each section of the doc gets corrupted as a result of me adding
in the icon into the header (I can see the {PAGE} changing to 0 after I run
the macro that adds in the icon to the header). Note that the icon in the
header sits in a table as I can’t work out how to have it in free space. I
also would like to know how to control the size of the image that is added to
the word doc prior to it being added (i.e. not have to add it and resize it
but to add it with the correct size).

The commands that add in the icon are given below:

Sub Generic_Portrait_Pic_Add4(iconname As String)
'this adds in the icon for the section of the doc
'locn is determined during the addition of the shape
Dim str_root_path As String
Dim shp
str_root_path = "D:\doc\icons\"
str_root_path = str_root_path & iconname 'create the complete
path
Set locn = Selection.Range
locn.Collapse Direction:=wdCollapseEnd
Set shp = ActiveDocument.Shapes.AddPicture(FileName:=str_root_path, _
linktofile:=False, Anchor:=locn)
With shp
.ScaleHeight 0.18, True 'resize the image
.ScaleWidth 0.18, True
.LockAnchor = False
.WrapFormat.AllowOverlap = False
.WrapFormat.Side = wdWrapLeft
.WrapFormat.Type = wdWrapSquare
End With
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument 'focus back on
the main doc
End Sub
 
S

Sean

We've had a similar problem with Word 2002, although in our case we weren't
adding graphics to the header. We were adding text though.

I wasn't directly involved in resolving this but I believe the solution was
a patch to Word.

Hope that helps.

Sean


Where am I? said:
Hello,
I have a (Word 2002) document with 100 plus sections in it. The layout of
the sections alternates between landscape and portrait.

I add in an icon to the headers programmatically using VB (different icon
dependant on the content of each section). This works fine. When I do this
the page numbers in each of the sections gets corrupted. I know this as if I
remove the last paragraph mark the text is fixed. I am using {PAGE} of
{NUMPAGES} in the footer to show the page number. The {NUMPAGES} field is
correctly calculated the {PAGE} is shown as 0 for each section when I add in
the icon into header.

I have read about the X of Y errors in the MVP html pages and the solutions
there do not resolve the problem so please do not direct me there.

Apparently each section of the doc gets corrupted as a result of me adding
in the icon into the header (I can see the {PAGE} changing to 0 after I run
the macro that adds in the icon to the header). Note that the icon in the
header sits in a table as I can't work out how to have it in free space. I
also would like to know how to control the size of the image that is added to
the word doc prior to it being added (i.e. not have to add it and resize it
but to add it with the correct size).

The commands that add in the icon are given below:

Sub Generic_Portrait_Pic_Add4(iconname As String)
'this adds in the icon for the section of the doc
'locn is determined during the addition of the shape
Dim str_root_path As String
Dim shp
str_root_path = "D:\doc\icons\"
str_root_path = str_root_path & iconname 'create the complete
path
Set locn = Selection.Range
locn.Collapse Direction:=wdCollapseEnd
Set shp =
ActiveDocument.Shapes.AddPicture(FileName:=str_root_path, _
 

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