C
cefrancke
I've been reading the help and I'm still confused.
I'm trying to get a grip on the Word Document Hierarchy, but to no
avail.
Section, Range, HeaderFooter ???????
The specific issue is, I want to insert a graphic at a specific point
in an existing Word document. In my case, the graphic will go in the
header of the first page, where from there it should of course show up
on the remaining page's header area.
I'm using a VBA in an Access module, opening the document....
from there I would like to insert the graphic (from a file) then
position and resize, etc.
....save the document and move on to the next.
I would like to start with a document where there is a pre-existing
graphic that says "Insert Graphic Here". This "blank" graphic will be
in the exact same place where the new graphic will be inserted.
So...I would like to open the doc, find the "blank" graphic, delete it,
insert the new graphic, position and resize (if necessary), save, and
move on to the next doc.
The "blank" graphic is not really necessary because the following code
works (though I'm sure, it cant be proper method), without a "blank".
However, there are some docs where there is a graphic in the header
already (btw there are sometimes 2-3 total, even distributed, ie
non-overlapping), so I would need a method to "find" the existing
graphic and delete it.
Here's the code I'm using now
'The app and doc are open already, at this point...
Dim objShp As Word.Shape
Dim objRng As Word.Range
Set objRng = objDoc.StoryRanges.Item(wdPrimaryHeaderStory) '
I'm guessing here...
Set objShp = objDoc.Shapes.AddPicture(filename:="C:\My.gif",
LinkToFile:=False, Anchor:=objRng)
With objShp
.Height = InchesToPoints(1)
.Width = InchesToPoints(1)
.Left = InchesToPoints(0.25)
.Top = InchesToPoints(0.25)
'Do I need to use relative positioning?
End With
I'm expecting a way to insert an object at any "coordinate" onthe
document in general or within a specific "section" (a word I use to
describe, Header, Footer, or Page Body)
I'm just not sure how to specify the Header, Footer, Body, or just the
document in general.
The general idea is to start with a base set of documents with a
"blank" graphic in the header.
For any reason (a new project, client, etc), create a new set of
documents from the originals where the appropriate graphic is inserted
in the same place where the "blank" graphic was, thus creating a set of
docs specific to a client or project or whatever.
The point is, I feel that my current method is a lucky guess, or a
"hack" and I can't seem to glean any proper methods from the confusing,
help.
Any ideas or references would be appreciated.
TIA
I'm trying to get a grip on the Word Document Hierarchy, but to no
avail.
Section, Range, HeaderFooter ???????
The specific issue is, I want to insert a graphic at a specific point
in an existing Word document. In my case, the graphic will go in the
header of the first page, where from there it should of course show up
on the remaining page's header area.
I'm using a VBA in an Access module, opening the document....
from there I would like to insert the graphic (from a file) then
position and resize, etc.
....save the document and move on to the next.
I would like to start with a document where there is a pre-existing
graphic that says "Insert Graphic Here". This "blank" graphic will be
in the exact same place where the new graphic will be inserted.
So...I would like to open the doc, find the "blank" graphic, delete it,
insert the new graphic, position and resize (if necessary), save, and
move on to the next doc.
The "blank" graphic is not really necessary because the following code
works (though I'm sure, it cant be proper method), without a "blank".
However, there are some docs where there is a graphic in the header
already (btw there are sometimes 2-3 total, even distributed, ie
non-overlapping), so I would need a method to "find" the existing
graphic and delete it.
Here's the code I'm using now
'The app and doc are open already, at this point...
Dim objShp As Word.Shape
Dim objRng As Word.Range
Set objRng = objDoc.StoryRanges.Item(wdPrimaryHeaderStory) '
I'm guessing here...
Set objShp = objDoc.Shapes.AddPicture(filename:="C:\My.gif",
LinkToFile:=False, Anchor:=objRng)
With objShp
.Height = InchesToPoints(1)
.Width = InchesToPoints(1)
.Left = InchesToPoints(0.25)
.Top = InchesToPoints(0.25)
'Do I need to use relative positioning?
End With
I'm expecting a way to insert an object at any "coordinate" onthe
document in general or within a specific "section" (a word I use to
describe, Header, Footer, or Page Body)
I'm just not sure how to specify the Header, Footer, Body, or just the
document in general.
The general idea is to start with a base set of documents with a
"blank" graphic in the header.
For any reason (a new project, client, etc), create a new set of
documents from the originals where the appropriate graphic is inserted
in the same place where the "blank" graphic was, thus creating a set of
docs specific to a client or project or whatever.
The point is, I feel that my current method is a lucky guess, or a
"hack" and I can't seem to glean any proper methods from the confusing,
help.
Any ideas or references would be appreciated.
TIA