I would like to print a document using VBA and want to pass the margin
paramaters from access to word. Can someone point me in the right direction.
BeWyched - 26 Jan 2007 18:01 GMT
I assume that you know how to create a Word object using VBA - say 'wdApp'.
The use:
With wdApp.ActiveDocument.Selection.PageSetup
.TopMargin = 'value_in_points'
.BottomMargin = 'value_in_points'
etc.
End With
You can set the above plus RightMargin, LeftMargin, MirrorMargin and Gutter.
You can convert the value in points to inches or centimetres, e.g.
.TopMargin = InchesToPoints(1.5)
Good luck
BW
> I would like to print a document using VBA and want to pass the margin
> paramaters from access to word. Can someone point me in the right direction.
BeWyched - 26 Jan 2007 18:05 GMT
Sorry - first line should read:
With wdApp.ActiveDocument.PageSetup
BW
> I assume that you know how to create a Word object using VBA - say 'wdApp'.
>
[quoted text clipped - 17 lines]
> > I would like to print a document using VBA and want to pass the margin
> > paramaters from access to word. Can someone point me in the right direction.
John Nurick - 26 Jan 2007 20:53 GMT
Hi Blanic,
You can do this sort of thing, after setting a reference to the
Microsoft Word X.X Object Library:
Dim oDoc As Word.Document
Set oDoc = GetObject("D:\Folder\File.doc")
With oDoc.PageSetup
.TopMargin = InchesToPoints(0.75)
.LeftMargin = CentimetersToPoints(2.5)
.RightMargin = CentimetresToPoints(1.905)
.BottomMargin = 72 'points
End With
>I would like to print a document using VBA and want to pass the margin
>paramaters from access to word. Can someone point me in the right direction.
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.
blanic - 29 Jan 2007 21:57 GMT
I appreciate your help but im still way out in left field. Tried both ways
and I didnt get them to work. Im accessing a network drive, call it e:\
cginst\test.txt
I want to open it in word then if possible pass margins at the same time. If
not just open the document itself, then ill make a macro in word, which I can
do. Thanks again
>I would like to print a document using VBA and want to pass the margin
>paramaters from access to word. Can someone point me in the right direction.
blanic - 29 Jan 2007 22:03 GMT
Nevermind, pulling your head out sometimes helps when solving this, I was
just stupid, got it to work, thanks again
>I appreciate your help but im still way out in left field. Tried both ways
>and I didnt get them to work. Im accessing a network drive, call it e:\
[quoted text clipped - 6 lines]
>>I would like to print a document using VBA and want to pass the margin
>>paramaters from access to word. Can someone point me in the right direction.