Solved

Save and restore user's ActivePrinter in MS-Access VBA

Posted on 2011-03-08
4
1,529 Views
Last Modified: 2016-10-10
In an MS-Access application, I need to save the user's current default printer before changing it to a Pdf-Writer to email a report.  On completion I must restore the user's default printer.

I have the code:
    Dim stUsersPrinter As String
    stUsersPrinter = Application.ActivePrinter

However I get a compile error:
    "Method or data member not found"

I am using MS-Access 2003.
Under Tools/References I have:
  Visual basic for applications
  Microsoft Access 11.0 Object library
  Microsoft DAO 3.6 Object Library
  Microsoft Visual Basic for Applications Extensibility 5.3
  Microsoft ADO Ext.2.8 for DDL and Security
  Microsoft ActiveX Data Objects Recordset 2.8 Library
  OLE Automation
  Adobe Acrobat 9.0 Type Library
  Find Printers type library
  Microsofoft Office 11.0 Object Library
  Windows Script Host Object model
  Acrobat Access 3.0 Type Library
 
0
Comment
Question by:David_Loxley
4 Comments
 
LVL 77

Accepted Solution

by:
peter57r earned 50 total points
ID: 35072518
Dim myDefPrt as string
'get current default printer.
mydefPrt= Application.Printer.DeviceName

' change the printer
Set Application.Printer = Application.Printers("printername")
' do your printing here.........


'then reset default.
Set Application.Printer = Application.Printers(mydefPrt)


0
 
LVL 19

Expert Comment

by:Eric Sherman
ID: 35075369
The code above posted peter57r will work in Access 2003 and later versions.

ET
0
 

Author Closing Comment

by:David_Loxley
ID: 35076308
Thanks - so simple when you know how!  I had been wading through all sorts of complexities.
0
 

Expert Comment

by:muneer alkouak
ID: 41836924
thanks, i will test it
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now