Print directly to the printer 
Author Message
 Print directly to the printer

Is it possible to Print directly to the printer using
Acces VBA, without creating a report?

I think need to use an API call, but I'm not sure which
one.  

The solution I am looking for would allow me to format and
position the text, and choose a printer to print to.



Mon, 06 Dec 2004 00:51:08 GMT  
 Print directly to the printer
Daniel, the Microsoft Scripting Runtime class/library includes support for a
printer, but i cannot imagine why one would use that when an Access report
is available.
--

~~~~~~~~~~~~~
Make a Great Day
TomG


Quote:
> Is it possible to Print directly to the printer using
> Acces VBA, without creating a report?

> I think need to use an API call, but I'm not sure which
> one.

> The solution I am looking for would allow me to format and
> position the text, and choose a printer to print to.



Mon, 06 Dec 2004 01:01:32 GMT  
 Print directly to the printer
Tom,

How do I get the Microsoft Scripting Runtime class/library?

and to explain my reasoning:

I'm trying to center text on a textbox on a report.  Both
horizontally and vertically.  I want the text to appear
exactly in the middle of the text box.  It is a large Memo
style textbox.  Access textbox only let's me center
horizontally.  

So I thought that if I could print directly to the printer
without using a report, then I could format and position
the text the way I want.

Quote:
>-----Original Message-----
>Daniel, the Microsoft Scripting Runtime class/library

includes support for a
Quote:
>printer, but i cannot imagine why one would use that when
an Access report
>is available.
>--

>~~~~~~~~~~~~~
>Make a Great Day
>TomG


message

>> Is it possible to Print directly to the printer using
>> Acces VBA, without creating a report?

>> I think need to use an API call, but I'm not sure which
>> one.

>> The solution I am looking for would allow me to format
and
>> position the text, and choose a printer to print to.

>.



Mon, 06 Dec 2004 02:23:47 GMT  
 Print directly to the printer
it is installed as part of Office 2000 and 2K. open any module in access for
design and select Tool/References from the VBA menu bar. scroll down until
you find Microsoft Scripting Runtime and check the box beside that entry.

there are a number of examples of it's use in MSDN online.

good luck

--

~~~~~~~~~~~~~
Make a Great Day
TomG


Quote:
> Tom,

> How do I get the Microsoft Scripting Runtime class/library?

> and to explain my reasoning:

> I'm trying to center text on a textbox on a report.  Both
> horizontally and vertically.  I want the text to appear
> exactly in the middle of the text box.  It is a large Memo
> style textbox.  Access textbox only let's me center
> horizontally.

> So I thought that if I could print directly to the printer
> without using a report, then I could format and position
> the text the way I want.
> >-----Original Message-----
> >Daniel, the Microsoft Scripting Runtime class/library
> includes support for a
> >printer, but i cannot imagine why one would use that when
> an Access report
> >is available.
> >--

> >~~~~~~~~~~~~~
> >Make a Great Day
> >TomG


> message

> >> Is it possible to Print directly to the printer using
> >> Acces VBA, without creating a report?

> >> I think need to use an API call, but I'm not sure which
> >> one.

> >> The solution I am looking for would allow me to format
> and
> >> position the text, and choose a printer to print to.

> >.



Mon, 06 Dec 2004 02:39:18 GMT  
 Print directly to the printer
Have a look at:
http://www.lebans.com/verticaljustification.htm
New April 07/2002

VerticalJustificationA2K.zip is a database containing a function to
allow for vertical centering of the contents of a Label or TextBox
control. Works with both Forms and Reports.

Access 2000 only!

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Quote:
> Tom,

> How do I get the Microsoft Scripting Runtime class/library?

> and to explain my reasoning:

> I'm trying to center text on a textbox on a report.  Both
> horizontally and vertically.  I want the text to appear
> exactly in the middle of the text box.  It is a large Memo
> style textbox.  Access textbox only let's me center
> horizontally.

> So I thought that if I could print directly to the printer
> without using a report, then I could format and position
> the text the way I want.
> >-----Original Message-----
> >Daniel, the Microsoft Scripting Runtime class/library
> includes support for a
> >printer, but i cannot imagine why one would use that when
> an Access report
> >is available.
> >--

> >~~~~~~~~~~~~~
> >Make a Great Day
> >TomG


> message

> >> Is it possible to Print directly to the printer using
> >> Acces VBA, without creating a report?

> >> I think need to use an API call, but I'm not sure which
> >> one.

> >> The solution I am looking for would allow me to format
> and
> >> position the text, and choose a printer to print to.

> >.



Mon, 06 Dec 2004 03:57:19 GMT  
 Print directly to the printer
I don't imagine that this is actually of any use, but in case anyone
is interested, this is 'old style' windows printing:
---------------------------------------------

Option Compare Database
Option Explicit
'00/12/04 dlg from KB Q105662 not in use
Option Private Module

Const mcModuleName = "mdlRP_PrintText"

Private Type DOCINFO
         cbSize As Integer
         lpszDocname As Long
         lpszOutPut As Long
      End Type

'Declare Function GetProfileString% Lib "Kernel" (ByVal lpAppName$, _
                       ByVal lpkeyname$, ByVal lpDefault$, _
                       ByVal lpReturnedString$, ByVal nsize%)
Private Declare Function PTM_apiCreateDC Lib "Gdi32" Alias "CreateDCA" (ByVal lpDriverName$, _
                       ByVal lpDeviceName$, ByVal lpOutput$, _
                       lpInitData As Any) As Long
Private Declare Function PTM_apiDeleteDC Lib "Gdi32" Alias "DeleteDC" (ByVal hDC&) As Long
Private Declare Function PTM_apiTextOut Lib "Gdi32" Alias "TextOutA" (ByVal hDC&, ByVal x&, ByVal _
                       y&, ByVal lpString$, ByVal nCount&) As Long
Private Declare Function Mylstrcpy& Lib "Kernel32" Alias "lstrcpy" ( _
                       ByVal lpString1 As Any, ByVal lpString2 As Any)
Private Declare Function PTM_apiStartDoc Lib "Gdi32" Alias "StartDocA" (ByVal hDC&, lpdi As DOCINFO) As Long
Private Declare Function PTM_apiStartPage Lib "Gdi32" Alias "StartPage" (ByVal hDC&) As Long
Private Declare Function PTM_apiEndPage Lib "Gdi32" Alias "EndPage" (ByVal hDC&) As Long
Private Declare Function PTM_apiEndDoc Lib "Gdi32" Alias "EndDoc" (ByVal hDC&) As Long
Private Declare Function PTM_apiRectangle Lib "Gdi32" Alias "Rectangle" (ByVal hDC&, ByVal X1&, _
                       ByVal Y1&, ByVal X2&, ByVal Y2&) As Long

      '-------------------------------------------------------------------
      'Start of Function
      '-------------------------------------------------------------------

Sub gsbRP_Printer(MyString$)
'00/12/04 dlg from KB Q105662 not in use
Dim lpReturnedString$
Dim MyDoc As DOCINFO
Dim MyDocumentname$
Dim nPrinter, nDriver, nDevice
Dim szDevice, szDriver, szOutPut
Dim hDC&, x&

         MyDocumentname$ = "CTM"

         '------------------------------------------
         ' Retrieve the currently selected printer as
         ' establish with the Control panel.
         ' Sample string as returned by lpReturnedString$:
         '
         '    HP LaserJet IIISi postscript,pscript,LPT1:
         '------------------------------------------
         lpReturnedString$ = Space$(128)
         nPrinter = PTM_apiGetProfileString("windows", "device", ",,,", _
                    lpReturnedString$, Len(lpReturnedString$))

         '-----------------------------------------
         ' Parse the string of its three components
         '-----------------------------------------
         nDevice = InStr(lpReturnedString$, ",")
         nDriver = InStr(nDevice + 2, lpReturnedString$, ",")
         szDevice = Mid$(lpReturnedString$, 1, nDevice - 1)
         szDriver = Mid$(lpReturnedString$, nDevice + 1, nDriver - _
                    nDevice - 1)
         szOutPut = Mid$(lpReturnedString$, nDriver + 1)

         '------------------------------------------
         ' Create the DOCINFO structure for StartDoc()
         '  - lpszDocname is name displayed in PRINTMAN
         '  - lpszOutPut is not used and set to NULL
         '------------------------------------------
         MyDoc.cbSize = Len(MyDoc)
         MyDoc.lpszDocname = Mylstrcpy(MyDocumentname$, MyDocumentname$)
         MyDoc.lpszOutPut = 0&

         '------------------------------------------
         ' Create the device context
         '------------------------------------------
         hDC& = PTM_apiCreateDC(szDriver, szDevice, szOutPut, 0&)

         x& = PTM_apiStartDoc(hDC&, MyDoc)
            x& = PTM_apiStartPage(hDC&)

         '------------------------------------------
         ' Rectangle arguments are X, Y, cX, cY
         '------------------------------------------
         'X& = PTM_apiRectangle(hDC&, 10, 10, 1000, 150)

         '------------------------------------------
         ' Second and third arguments are the X and Y
         ' coordinates on paper.
         '------------------------------------------
         x& = PTM_apiTextOut(hDC&, 30, 20, MyString$, Len(MyString$))

         x& = PTM_apiEndPage(hDC&)
         x& = PTM_apiEndDoc(hDC&)

         '------------------------------------------
         ' Release the device context when done
         '------------------------------------------
         hDC& = PTM_apiDeleteDC(hDC&)

End Sub



Tue, 07 Dec 2004 10:02:21 GMT  
 Print directly to the printer
Download OrchidPrinter at http://www.orient-orchid.com to help you.


Tue, 07 Dec 2004 12:45:22 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. print directly to win2k printer share?

2. Printing directly to a printer

3. Printing directly to a printer from VB.

4. How to print directly to the printer?

5. Printing directly to the printer

6. Help! Printing directly to the Printer

7. Printing directly to a printer from VB

8. Newbie: Printing directly to a printer from IE browser

9. Printing directly to a printer from Web Server

10. Printing directly to printer w/o using Print Manager

11. Printing Directly to Printer

12. How to print directly to printer?

 

 
Powered by phpBB® Forum Software