Set Printer in VBA-Access - learnit

Home Top Ad

Post Top Ad

Sunday, May 16, 2021

Set Printer in VBA-Access

Set Printer in VBA-Access

Set Printer in VBA-Access

VBA-Access

VBA stands for Visual Basic for Applications (the application being of course Microsoft Access) and is the technology and tools used to program and automate this application. ... Manage more powerful procedures that an Access macro lacks. Communicate with other applications and platforms. It’s not only used just within the framework of Microsoft Access Database but other applications too including Microsoft Excel, Microsoft Word, Microsoft Outlook to name a few.It has the power to communicate with other applications beyond the Microsoft range and even the Microsoft Windows operating system across other platforms.So, learning the principles of VBA using Access as the tool environment will stand you in good stead for the other applications should you wish to program and code them in the future.The only difference between other applications when wanting to use VBA will simply be learning to load and work with different libraries.Typical reasons why you would use Microsoft Access VBA include being able to:


1.Manage smaller re-usable procedures (globally).

2.Create you own defined functions.

3.Hold variables in memory (globally).

4.Attach code to an event i.e. a button on a form.

5.Manage more powerful procedures that an Access macro lacks.

6.Communicate with other applications and platforms.

7.Gracefully handle errors (when they happen)


Returns or sets a Printer object representing the default printer on the current system. Read/write


Syntax Description
Printers!devicename The devicename argument is the name of the Printer object as returned by the DeviceName property.
Printers("devicename") The devicename argument is the name of the Printer object as returned by the DeviceName property.
Printers(index) The index argument is the numeric position of the object within the collection. The valid range is from 0 to Printers.Count-1.

You can use the properties of the Printer object to set the printing characteristics for any of the printers available on your system.


Use the LeftMargin, RightMargin, TopMargin, BottomMargin, ColumnSpacing, RowSpacing, DataOnly, DefaultSize, ItemLayout, ItemsAcross, ItemSizeHeight, and ItemSizeWidth
properties to specify how Microsoft Access should format the appearance of data on printed pages.


Example

Private Sub cmdPrint_Click()
Debug.Print Application.Printer.DeviceName
Set Application.Printer = Application.Printers("Microsoft Print to PDF")
Debug.Print Application.Printer.DeviceName
Set Application.Printer = Application.Printers("Adobe PDF")
Debug.Print Application.Printer.DeviceName
End Sub

Please Watching My Video is Below

No comments:

Post a Comment

Post Top Ad