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
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