PDA

View Full Version : Need Help to create a simple macro



boughtpassat
01-13-2010, 04:01 PM
Hi everyone,
I am not a regular macro writer, but need to write one that will print a range of pages. Every month I have to send a report to a large audience that has 4 sections (MS Word doc). I would like to provide four different buttons at the beginning on or near the TOC that will allow the recipients to print only their section of the report. I dont mind editing the code each time to update the page ranges for the macro.

I appreciate any and all help.

Using MS word 2000

macropod
01-13-2010, 05:23 PM
Hi boughtpassat,

If your intention is to prevent people from printing the other sections, then I'm afraid you're out of luck. If you provide the content, any method you use to protect it can be got around. With anything that relies on macros, the simple workaround is to choose the option you're given when the document is opened to disable macros.

boughtpassat
01-14-2010, 07:15 AM
No that is not the intention, it is rather to provide the convenience to someone only needing to print section 3, then they will click that button and it will print the page range for that section. The other sections of the document do not apply to them.

Is it possible to create a macro that will print my specified page ranges? A separate macro/button for each section of the word doc.

fumei
01-14-2010, 09:33 AM
Yes. If these are true Word sections. A VERY simple example attached (I used Continuous Sections to keep it small, and used..GASP!...Selection).

Click PrintSection1, or PrintSection2...etc. on the top toolbar.

boughtpassat
01-14-2010, 12:14 PM
I attached an example of my report. Could someone help me to create a macro where:

Someone clicks "Print Div 1 Report" and it will print p3-4
Someone clicks "Print Div 3 Report" and it will print p5-6

And so on...
thanks so much for everyone's help thus far. I do apologize if the previous attachment has addressed.

2591

boughtpassat
01-15-2010, 07:04 AM
bump

fumei
01-15-2010, 11:33 AM
Record a macro doing what you want. Printing pages 3 to 4.

Look at the code.

boughtpassat
01-15-2010, 12:27 PM
Thanks for your help. This doesnt seem to print the footer of my doc..???

fumei
01-15-2010, 01:12 PM
Are you saying you printed pages 3 to 4 (and they have a footer), but the footer is NOT printed? Because I just took your example file, recorded a macro printing pages 3 and 4....and the footer is printed.

BTW: I strongly, strongly, strongly recommend you learn to use Styles. You have numerous paragraphs that are empty, some with Tabs at the start (for whatever reason). Bad idea.

Also, do have Show/Hide on? If you are doing serious use of Word, it is a good idea to have it on.

geekgirlau
01-18-2010, 05:19 PM
If you break your document into sections (insert a section break before each division) then the macro is simple:


ActiveDocument.PrintOut Range:=wdPrintRangeOfPages, Pages:="s2"


where "s2" is section 2 of the document. This also removes any requirement to work out how many pages are required for each Division.

fumei
01-19-2010, 01:43 PM
Doh!