PDA

View Full Version : creating a macro that prints certain pages?



Red_Bandit
03-15-2009, 09:58 AM
Hello, this is my first post here :)

Is it possible to create a macro in MS Word that can print pages with certain words on them? I have a 600+ page document in which I use the find function to look for the word "systematic" and then print the current page, it wastes a lot of time. I print the pages with the word "systematic" around 120 times. The pages are never the same so is there anyway a macro can be made?



thanks!

fumei
03-16-2009, 09:33 AM
Not without finding the word.

Question: is your code using Selection? If it is, then that would decidely be slower than using Range.

Since you mention the pages are never the same, the next question is: are any pages "chunked"?

That is, could you be printing pages 7 - 11 (7, 8, 9, 10, 11)?

Or is it essentially you are printing one page (whatever it is) at a time.

It may help to post some actual code.

Red_Bandit
03-16-2009, 10:16 AM
Hi fumei thanks for replying.

I have no code at all. I am pretty new to making macros. :(

Basically what I am looking for is to print every page that has the word "systematic" on it.

The pages arent chunked. Today the report is 657 pages. Friday the report was 649 pages. It all depends on the amount of transactions per fund. So today I looked and the first instance of the word "systematic" is on page 3 on todays report. On Friday's report it was on page 6.


I made a simple "Print current page" macro shortcut button on my MS Word menu bar. So after I open the report, i would press "CTRL F" and then type "systematic" and press the "printcurrentpage" macro button and then press the "NEXT" button to find the next occurance and then repeat by pressing the "printcurrentpage" button.

I hope that helps clarify things a bit


thanks

fumei
03-16-2009, 11:09 AM
No, I don't mean today is on page 3, tomorrow on page 6. I mean:

"That is, could you be printing pages 7 - 11 (7, 8, 9, 10, 11)?"

Excuse me, but I do not understand:

"I have no code at all. "

and

"I made a simple "Print current page" macro "

Are these not contradicting? That macro is code. Here is something that may help - it uses Range...not Selection, which I suspect you are using.

Dim r As Range

Set r = ActiveDocument.Range
With r.Find
Do While .Execute(FindText:="systematic", _
Forward:=True) = True
' the next line IS THE PAGE NUMBER of the
' currently found "systematic"
r.Information(wdActiveEndAdjustedPageNumber)
' print each page?
' or collect all these numbers, and THEN print those pages?
Loop
End With

Red_Bandit
03-16-2009, 01:36 PM
Hi

What I mean is that I created the print current page macro just by recording the steps (File -> print -> select current page -> click ok). Then I saved that macro as a button on the top of my MS Word tool bar. So everytime I open MS Word, that button will appear.

Thats a completely different macro from the macro I am trying to build in which I have not started yet. Thats what I meant by not having any code. sorry for the confusion.


There is over 600+ pages every day for this report. I print out each page that has the word "systematic". I do not think I can do the print page range as I print about 120 or so pages.


I see you used this code but it confused me

r.Information(wdActiveEndAdjustedPageNumber)

thank you

Red_Bandit
03-18-2009, 04:55 PM
bump ?? :(

fumei
03-20-2009, 09:19 AM
Bump to what? What are you asking?

"I see you used this code but it confused me

r.Information(wdActiveEndAdjustedPageNumber)"

I tried to explain that in the comment.
' the next line IS THE PAGE NUMBER of the
' currently found "systematic"
r.Information(wdActiveEndAdjustedPageNumber)
Say you have "systematic" on page 3, page 14, page 23, page 105..

it is the page number of the currently found "systematic'

that is...the code finds "systematic" and that number is 3, finds the next 'systematic" and that number is 14, finds the next 'systematic" and that number is 23, finds the next 'systematic" and that number is 105...


I do not think I can do the print page range as I print about 120 or so pages.Care to clarify that?