M
Mei Qin
Hello,
I create a word document from vb application. I format the
header and footer and insert a couple of files into the
word documment. I use the selection object for both
formatting header and footer and inserting files. It works
fine the first time I run the program. But the second
time when I run it. The files did not inserted into the
document.
Here is the code I use to format footer:
objWord.Sections(1).Footers
(wdHeaderFooterPrimary).Range.Fields.Add
Range:=Selection.Range, Type:=wdFieldPage
Selection.TypeText Text:=" of "
objWord.Sections(1).Footers
(wdHeaderFooterPrimary).Range.Fields.Add
Range:=Selection.Range, Type:=wdFieldNumPages
Selection.ParagraphFormat.Alignment =
wdAlignParagraphCenter
After I format the document footer, I have the follwoing
line of code:
objWord.Content.Select
With Selection
Insert file here
end with
It looks like the selection is still in the footer area.
Is it anyway I can detect where the selection is and how
to redefine the selection?
Thanks for any help!
Mei
I create a word document from vb application. I format the
header and footer and insert a couple of files into the
word documment. I use the selection object for both
formatting header and footer and inserting files. It works
fine the first time I run the program. But the second
time when I run it. The files did not inserted into the
document.
Here is the code I use to format footer:
objWord.Sections(1).Footers
(wdHeaderFooterPrimary).Range.Fields.Add
Range:=Selection.Range, Type:=wdFieldPage
Selection.TypeText Text:=" of "
objWord.Sections(1).Footers
(wdHeaderFooterPrimary).Range.Fields.Add
Range:=Selection.Range, Type:=wdFieldNumPages
Selection.ParagraphFormat.Alignment =
wdAlignParagraphCenter
After I format the document footer, I have the follwoing
line of code:
objWord.Content.Select
With Selection
Insert file here
end with
It looks like the selection is still in the footer area.
Is it anyway I can detect where the selection is and how
to redefine the selection?
Thanks for any help!
Mei