SkyFlyer Posted September 30, 2007 Report Share Posted September 30, 2007 Hello all. I have done some searching on the forum and found bits and pieces, but not the answer. Or at least enough to help me with my issue. I want to create a Macro to cause Word 2007 to print a document. I do not want Word to open and display a document. I have tried a number of different combinations in the Activate/Launch Program window. One of the messages I get is specified file does not exist. Once I actually got Word to open, but it would not print based on the command-line switch /p. If someone could get me pointed to a previous forum article discussing this, or suggest a sample, I would really appreciate it. My program is C:\Program Files\Microsoft Office\Office12\Winword.exe. My file is D:\BobsData\My Word\Computer\Sample Print.docx. I understand that we can just put the file name in the Program/Path name and use the file association to open the file. But if you don't specify the program, how do you specify command-line switches. I want to use switches /p /n /q for Word (print, no new document, no splash) but even when I put them in Program Parameters, it does not seem to take. I have tried with and without quotes. I'll keep working at it. Appreciate any help, and thanks in advance. Bob Quote Link to comment Share on other sites More sharing options...
floyd Posted September 30, 2007 Report Share Posted September 30, 2007 I want to use switches /p /n /q for Word (print, no new document, no splash) but even when I put them in Program Parameters, it does not seem to take. Microsoft Word does not have a switch to print a document from the command-line. The /p you are referencing is for something else. Quote Link to comment Share on other sites More sharing options...
SkyFlyer Posted October 1, 2007 Author Report Share Posted October 1, 2007 Bummer. Is there no way to do the print in Word? That is odd. I was sure there was a /P. Maybe older versions of Word? Any suggestions on what to use to do the print? I'd use a text editor, but I have some graphics to print in addition to text. I'll keep looking and trying. Thanks ... Quote Link to comment Share on other sites More sharing options...
Namino Posted October 1, 2007 Report Share Posted October 1, 2007 Hi, I think you just need to use /mFilePrintDefault. Try this: <LAUNCHDEL2:0:01C:\Program Files\Microsoft Office\Office12\Winword.exe<PARAM>D:\BobsData\My Word\Computer\Sample Print.docx /mFilePrintDefault1><TDELAY:3><WCLS:- Microsoft Word> Quote Link to comment Share on other sites More sharing options...
floyd Posted October 1, 2007 Report Share Posted October 1, 2007 That is odd. I was sure there was a /P. Maybe older versions of Word? No, not in any older version either. Bummer. Is there no way to do the print in Word? Yes. Namino has it right. Use the built-in Word Command macro. You will, however, need to wrap the full path document-to-print name in quotation marks within the Program Parameters field i.e "D:\BobsData\My Word\Computer\Sample Print.docx". Quote Link to comment Share on other sites More sharing options...
Cory Posted October 1, 2007 Report Share Posted October 1, 2007 We covered all this in a previous post and the only reasonable solution was to run the Word macro with a command line switch. I have tried it and it works well. There were some good examples there as I recall. Quote Link to comment Share on other sites More sharing options...
SkyFlyer Posted October 2, 2007 Author Report Share Posted October 2, 2007 OK thanks. That is what I was asking for. A pointer to a post that discussed that. I'll keep looking for it. There is so much stuff that shows up. I need to learn the lingo and narrow it down. Perhaps someone would know the author who discussed this. I could search by that. Thanks for your help. Quote Link to comment Share on other sites More sharing options...
SkyFlyer Posted October 2, 2007 Author Report Share Posted October 2, 2007 OK, I found a post on printing files. And I will try Acrobat this time. That would work for me instead of Word. I cannot seem to the print macro to work in Word. But, I cannot get past error message "The specified file does not exist" in setting up ME. I have set the path with Change Directory/Folder. I have tried just about every combination I can think of using Program Path/Name and Program Parameters in the Activate/Launch Program window. I used some of Cory's examples for Acrobat, still no go. I have used complete path names, just the file name, quotes, no quotes. I'll try a little longer and then will let it sit. I suppose I should make a short list of exactly what I have done and post that. Thanks for you help ... Bob Quote Link to comment Share on other sites More sharing options...
Cory Posted October 2, 2007 Report Share Posted October 2, 2007 How funny. I just wrote a fun macro that will print every PDF in a given folder. Timing had been a problem in the past so I came up with a better way. Here is the command I used: <LAUNCHDEL2:0:01C:\Program Files\Adobe\Acrobat 6.0\Acrobat\Acrobat.exe<PARAM>/t "%T3%" "%T2%"> T3 is the complete file UNC path and the T2 is the printer name as it appears in the printer control panel. So if you wrote it all out in run prompt might look like: “C:\Program Files\Adobe\Acrobat 6.0\Acrobat\Acrobat.exe” /t "C:\temp\test1.pdf" "HP LaserJet 4+" On common problem is that if you get the file name from somewhere else like Repeat With Folder you need to remember to encapsulate it with quotes if there’s a chance there will be spaces in the path. Also, of course, you will need to change the program’s file path accordingly to your installation of Acrobat. Another oddity is that Adobe really wants to have an open, empty instrance of Acrobat running. I figured out why but it's a long story. Perhaps if you posted an example I could see where you're going wrong. Also try to make it work from the run line first then substitute for variables. Click here for my web page on the subject if you have not already reviewed it. If you're interested I attached my recent macro. PDFPrint.mex Quote Link to comment Share on other sites More sharing options...
Seabass Posted January 31, 2008 Report Share Posted January 31, 2008 Good morning all, I am trying to generate a bunch of report every night. The report originate in a MS Access database. We publish the report in a pdf format on a folder. Each filename is refer to on an intranet web page where users can click on the desired reprot and it open up in pdf. To get the report in pdf, i created a button on the database switchboard called " Publish Report" I then wrote (with some assistance from my IT Dept. ) a little code as an event procedure when you click the button. it look like this for each report: DoCmd.OpenReport "rpt WCC DAILY MORNING REPORT SS REPORT", acViewPreview, "", "", acNormal DoCmd.PrintOut acPrintAll, , , acHigh, 1, True DoCmd.Close acReport, "rpt WCC DAILY MORNING REPORT SS REPORT" So to automate this, i create a macro in Macro Express that : Open the database file. (Autoexec macro within the database open up the switchboard form) Delay 15 seconds (to make sure it all load up properly) Text type "Enter" (The button has focus as it is the first selection in the tab order in Access) Once this run, the code "print" each report using the pdf printer to get the pdf report where we want it. So my question to you all is what is the best way to get the macro to select the button and execute it.... A few nights it did not ran as planned even though the schedule time nad macro express were all set properly. Should i use a Get focus or other function versus the text type ???? or can i run a MS Access macro directly from Macro Express, bypassing the text type and all.... FYI, we had the "publish macro" in Access setup in the autoexec macro before, but as we add report, the execution time was too long every time we open up the database... Thanks for any input.... Seabass Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.