Re: Automatic generation of template files by Helmut
Helmut
Sat Apr 29 04:07:38 CDT 2006
Hi Nathan,
software development is a process of trial and error.
More or less, of course.
With starting from a blank document,
inserting a picture,
saving as,
and repeating all,
a new picture would be _added_ to the header
with each run.
So deleting the inserted picture is an essential step,
which I didn't think of, at first.
Have a close look at the section,
which sizes and places the picture.
This one seems to work quite right.
Though I'd strongly advise,
not to try to create all 1000 dots in one go.
Sub Test0796()
Dim sPth As String ' Source Path
Dim tPth As String ' Target Path
Dim sFil As String ' Source File
Dim tFil As String ' Target File
sPth = "c:\test\jpg\"
tPth = "c:\test\dot\"
sFil = Dir(sPth & "*.jpg", vbNormal)
While sFil <> ""
tFil = sFil
tFil = Left(tFil, Len(tFil) - 3)
tFil = tFil & "dot"
With ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary)
.Shapes.AddPicture _
FileName:=sPth & sFil, _
LinkToFile:=False, _
SaveWithDocument:=True
.Shapes(1).LockAspectRatio = msoFalse
.Shapes(1).RelativeHorizontalPosition =
wdRelativeHorizontalPositionPage
.Shapes(1).RelativeVerticalPosition =
wdRelativeVerticalPositionPage
.Shapes(1).Height = InchesToPoints(11)
.Shapes(1).Width = InchesToPoints(8.5)
.Shapes(1).Top = InchesToPoints(0)
.Shapes(1).Left = InchesToPoints(0)
ActiveDocument.SaveAs tPth & tFil
.Shapes(1).Delete
End With
sFil = Dir
Wend
End Sub
Beware of linebrakes by the newsreader.
HTH
--
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"