Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling The Printer Control Panel In VBA 1

Status
Not open for further replies.

EvilaJC

MIS
Jul 15, 2003
6
US
My users are connecting to my Access database utilizing terminal server (please don't ask me why-- it's just the container I was given to work with). They are effectively locked out of all other functions on the terminal server except for Access.

My problem is this: I tried to program the report print controls to select the appropriate size/margins/orientation each time they print-- according to Microsoft's recommended specifications-- however, Access 2000's restrictions regarding object design prevent the programatic changes from sticking. (The procedure calls for the report to be opened in design view and altered immediately prior to re-opening and printing.) This worked great in development, however, once the database became shared again, the settings were overridden.

My question is this: How do I either: (1) Force the printer settings in the same call that the report is printed, rather than open the report in design mode and then reopen it to print, or (2) Program (in VBA) a command button to call the printer control panel module so that the end user can alter the printer settings themselves? This would also allow them to convert reports to PDF by selecting the PDF writer should they decide to do so.

Any help you can offer would be greatly appreciated.
 
I'm not sure I completely understand what you need, but what comes to mind is that you need to use the PrtDevMode and PrtMip properties of the report. These are trickier to use than most properties, so start by studying the example code in the help file. You can also search the Knowledge Base for more sample code for these properties.

These properties will allow you to change printer properties such as source tray, copies, orientation, paper size, etc. from within code. I've successfully used them to decide at run time what arrangement of address labels (number across and down) to print, for example.

Rick Sprague
Want the best answers? See faq181-2886
To write a program from scratch, first create the universe. - Paraphrased from Albert Einstein
 
Thanks for the suggesstions, Rick. I've subsequently been able to run around previous problem, but now have run into a new (and hopefully simpler) snag. If anyone could help, I'd appreciate it.

For reasons not important enough to go into here, I have my users locked completely out of all Windows functions except for the database they're working in. However, it is necessary for them to get into the Windows Control Panel to modify their printers, select different printers as default, etc.

I can call the Control Panel using a simple DOS command line shell call, however, I do not want my users to get the full-blown Windows Control Panel, only the "Printers and Faxes" module specifically. Is there an extension to the "c:\windows\system32\control.exe" shell call that will specifically call only the printers and faxes module?

Thanks,
Rusty
 
Not that I can think of.
To my mind you need to be changing the report printer in code. If you are using Access 2002 then you can use the printer object, just like in Excel 2000.
If you are not then you need to code the prtdev thingy like Rick suggests. Check out for a demo & code.
As an alternative, you could check out the solution from:
This seems pretty good and has a wide range of options, though I can't say I've used it.

hth

Ben

----------------------------------------------
Ben O'Hara

"Where are all the stupid people from...
...And how'd they get so dumb?"
NoFX-The Decline
----------------------------------------------
 
there might be a better way but this will work. create a shortcut to Printers and Faxes from the control panel. the create a batch file ("c:\Printers and Faxes.lnk" include the quotes) that opens the shortcut. then on a button on the form put this code to call the batch file:

Private Sub Command7_Click()
Dim fpath
fpath = "c:\test.bat"

Call Shell(fpath, vbHide)
End Sub
 
Perfect, drctx! I was halfway there, creating a link to the Printers folder, but didn't think to put it in a batch file with the quotations. My users will still have access to Windows Explorer and other Control Panel functions, but having this come up first will definately get what I needed done!

Thanks again!
 
Genius drctx!
Have a star.

B

----------------------------------------------
Ben O'Hara

"Where are all the stupid people from...
...And how'd they get so dumb?"
NoFX-The Decline
----------------------------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top