Problems with Margins in VBA (Word)

francozola25

Board Regular
Joined
Aug 22, 2007
Messages
96
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

Code:
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.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
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.
 
Upvote 0
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
 
Upvote 0
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?
 
Upvote 0
Have you tried anything I mentioned in my post?

Specifically applying DisplayAlerts to the Word object.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,215,754
Messages
6,126,681
Members
449,328
Latest member
easperhe29

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top