# Problems with Margins in VBA (Word)



## francozola25 (May 19, 2008)

Hello

I was wondering if anyone could help me. I am trying to run a macro that will print off word docs. However my macro stops at a doc, stating, there is a problem with the margins of section.... click yes or no. If i click yes the macro wil continue. I want to find a way of not having to call the message

I have tried, application.displayalerts = wdAlertsNone 

but no luck

I have also tried the following


```
Dim x As Boolean

x = Options.PrintBackground


Options.PrintBackground = False
bDoc.PrintOut
Options.PrintBackground = x
```

This works but now i get a message saying Printing page 1 of .....
I do not want this as my code is in a loop and i print off alot of files.

Screenupdating has not done anthing either.


----------



## Norie (May 19, 2008)

Firstl Application.DisplayAlerts doesn't apply to Word, that's specific to the instance of Excel the code is running.

I don't know if there is a Word equivalent I'm afraid.

Oops, spoke to soon, Word has it too - you'll just need to reference the Word application object when using it.

But I'm afraid even that might not solve the problem - that message isn't actually generated by Word.

It's something to do with the print driver(s)/spools/something.

If you really want rid of it then I'm sure I've seen code using the Windows API to do so.


----------



## Macropod (May 20, 2008)

Hi francozola25,

the message is being generated because the page margins you've defined are too narrow for the printer's configuration. Most printers need around 0.25in along the sides and sometimes at the top or bottom also for the paper transport mechanism. Sometimes, you can reduce the default value and get a slightly wider print area. You do this via the printer's setup tools - any changes will apply to all applications that interrogate the printer's configuration. Alternatively, the best solution may be to fix the document's margins - otherwise you run the risk of not being able to print out everything that appears on screen.

Cheers


----------



## francozola25 (May 20, 2008)

Thanks for that

It is just there is around 200 documents to print off, is there not a bit of VBA code that could automatically click yes when yes and no comes up about the margins?


----------



## Norie (May 20, 2008)

Have you tried anything I mentioned in my post?

Specifically applying DisplayAlerts to the *Word *object.


----------



## francozola25 (May 24, 2008)

Sorry for not getting back to you earlier Norie

No Display Alerts doesn't seem to do anything. The macro works fine, it is just i have a progress bar running in the macro to print off the selected files. Everytime one is printed i have this annoying message stating printing 1 of 4 pages etc. This pops up with the progress bar.

So annoying, i just need a command to disable this, i have tried the printer server properties but still cannot disable the message


----------



## francozola25 (May 25, 2008)

Got sorted with a bit of API thanks all for pointing me in the right direction.


----------



## vincechiew (Aug 4, 2008)

I have the same issue, would it be possible to forward the solution?


----------

