Desktop shortcut & macro work .. mostly
Thanks, MacroPaul. Your sugg to add a Document_Open macro sounds feasible, but I don't yet know enough about writing macros to accomplish that .. I know only how to record what the macro recorder observes me doing. Lame, I know, I'm just not there yet.
Here's what I've managed to get a recorded macro to do .. but it needs some work. The contents of the macro are in the attached file "Print_Labels().txt.
The whole idea with this invocation of Word is for the Desktop shortcut to invoke Word, telling it to open an already-written document that has the labels already formatted. The shortcut-referenced macro then opens a Recipient List (which is an Excel spreadsheet containing all of the addressees’ data), imports all the records into the formatted label pages, prints them, and then exits the program. The command line I’m using in the Desktop shortcut is:
"C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE" C:\Users\Administrator\Desktop\PrintLabels.docx /mPrint_Labels
[ A word about that path: I’m developing this procedure at home in my Win7 64bit Office 2010 32bit environment. I know that the path to WINWORD will be different when I migrate the project to the target machine: an XP 32bit Microsoft Office 2007 32bit environment. ]
When invoked, even though the macro I recorded did observe me entering/responding to all prompts all the way through to the last step before exiting the program (which was to turn off the recorder), the Desktop shortcut, and the instance of Word & the referenced macro (Print_Labels), produced these concerns:
SQL WARNING
This pop-up message came up immediately:
! Opening this document will run the following SQL command:
SELECT * FROM ‘Labels$’
Data from your database will be placed in the document. Do you want to continue?
[ Yes ] [ No ] [ Help ]
The answer to the question is always [ Yes ], and I did click that button when I was recording the macro. How can I get the macro to assert the [ Yes ] answer at this point and not pause, awaiting the operator to click the [ Yes ] button? Is the answer-file technique used in some other applications appropriate here?
PRINT MARGINS WARNING
As it was getting ready to print the label pages, this warning came up:
? The margins of sections 1, 2, 3 are set outside the printable area of the page. Do you want to continue printing?
[ Yes ] [ No ] [ Help ]
The answer to the question is always [ Yes ], and I did click that button when I was recording the macro. (I saw the online Help advice to anticipate & ignore this message when printing multiple-across labels.) Again: How can I get the macro to assert the [ Yes ] answer at this point and not pause, awaiting the operator to click the [ Yes ] button?
DOCUMENT SAVE POP-UPS
All of the remaining Print operations happen without further operator response, but two prompts for the operator’s wishes about saving changes to the two documents that were modified & created: No, neither is to be saved.
! Do you want to save changes you made to “Form Letters1”?
[ Save ] [ Don’t Save ] [ Cancel ]
-and-
! Do you want to save changes you made to “PrintLabels.docx”?
[ Save ] [ Don’t Save ] [ Cancel ]
Again the appropriate responses (I want the macro to respond to) are: [ Don’t Save ], because all I want to happen is to print the labels; this set won’t need to be printed again.
PROGRAM EXIT
The screen reverts to a blank document, and the last thing the macro recorder saw me do was to stop recording the macro. I would now like for Word to exit, but the macro is no longer in charge. How to get it to exit now?
A WORD ABOUT THE ENVIRONMENT
I’m developing this in a Parallels-managed virtual PC Win7 64bit Office 2010 32bit environment on an Apple iMac. The printer is an Epson CX4200, and the virtual PC connectivity to it is working fine. I mention this because you may see code in the macro that refers to this convoluted development platform. Once I get it working in this environment, I hope to make the required changes necessary to get it to function properly in the target environment: a real PC running XP 32bit & Microsoft Office 2007 32bit. ]
THE MACRO
The macro that was recorded is attached. I have very little experience with writing/editing macros. Maybe you can suggest how to modify it to achieve the desired results?
|