B
booger
I am automating Word 2000 from VB6 SP6. (I have extensive Excel VBA
experience, but I rarely work with the Word object model - it is just
different enough from the Excel object model to be very frustrating at
times.)
I have a shape object in the main body of my document that I am
pasting into a header like so:
Set grpTemp = .ActiveDocument.Shapes.Range(aShapes).Group
grpTemp.Select
.Selection.Cut
With .ActiveDocument.Sections(SectionNum).Headers(wdHeaderFooterPrimary)
.Range.Paste
End With
When SectionNum=1, then everything works fine. Next, I add a section
break(Section 2), and add some text. Here is how I add the section
break:
With AppWord.Selection
.InsertBreak wdSectionBreakNextPage
.EndOf wdStory
With AppWord.ActiveDocument.Sections(.Information _
(wdActiveEndSectionNumber)).Headers(wdHeaderFooterPrimary)
.LinkToPrevious = False
.Range.Delete
End With
End With
Note that immediately after adding the section break, I break the link
to the previous section's header and clear the header range. At this
point, I add another section break (Section 3) using the section break
code and I perform the pasting code again with SectionNum=3.
Here is where the problem is: even though I am pasting my shape object
into the header of section 3, the shape appears in the header for
section 1. Now, to make sure that I am doing everything OK, I inserted
a line of code (.Range.Text = "hello") just before the .Range.Paste
line to write some text to the header. The "hello" text appears in the
Section 3 header (as it should) but when I continue to the
..Range.Paste line, the shape object which is pasted from the clipboard
stubbornly appears in Section 1.
Any ideas? Thanks in advance for your assistance.
sincerely,
drew richards
experience, but I rarely work with the Word object model - it is just
different enough from the Excel object model to be very frustrating at
times.)
I have a shape object in the main body of my document that I am
pasting into a header like so:
Set grpTemp = .ActiveDocument.Shapes.Range(aShapes).Group
grpTemp.Select
.Selection.Cut
With .ActiveDocument.Sections(SectionNum).Headers(wdHeaderFooterPrimary)
.Range.Paste
End With
When SectionNum=1, then everything works fine. Next, I add a section
break(Section 2), and add some text. Here is how I add the section
break:
With AppWord.Selection
.InsertBreak wdSectionBreakNextPage
.EndOf wdStory
With AppWord.ActiveDocument.Sections(.Information _
(wdActiveEndSectionNumber)).Headers(wdHeaderFooterPrimary)
.LinkToPrevious = False
.Range.Delete
End With
End With
Note that immediately after adding the section break, I break the link
to the previous section's header and clear the header range. At this
point, I add another section break (Section 3) using the section break
code and I perform the pasting code again with SectionNum=3.
Here is where the problem is: even though I am pasting my shape object
into the header of section 3, the shape appears in the header for
section 1. Now, to make sure that I am doing everything OK, I inserted
a line of code (.Range.Text = "hello") just before the .Range.Paste
line to write some text to the header. The "hello" text appears in the
Section 3 header (as it should) but when I continue to the
..Range.Paste line, the shape object which is pasted from the clipboard
stubbornly appears in Section 1.
Any ideas? Thanks in advance for your assistance.
sincerely,
drew richards