Printing from Access to Word

  • Thread starter Thread starter blanic
  • Start date Start date
B

blanic

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.
 
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
 
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 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
 
Nevermind, pulling your head out sometimes helps when solving this, I was
just stupid, got it to work, thanks again
 
Back
Top