Hi experts,
I am in desperate need of some advise and help from more experienced folk than me.
I am currently implementing a custom Outlook contact form that will contain a BarCode label object (BarcodeX from FathSoft). The object itself has already been integrated into the outlook form and works pretty well. Now, my plan was/is to place a custom button below that object and add some VBA code to its Click event routine. It should print the Barcode object itself either on the default windows printer or on a specifiable network printer (whatever is most easy to achieve).
Is there a way to achieve printing that single object or a bitmap graphic which has beend created from it?
Could you help me coding that (because I am totally new to this mess)?
I can imagine you are not that familiar with BarcodeX (neither am I). BarcodeX objects are activeX components which support certain methods (not sure about VBA though):
-------------
Here's what BarcodeX help file is saying:
ASP & scripting
BarcodeX control has COM interface “CbarcodeX” and it has these methods;
CreateBMP(Filename, BarcodeType, BarcodeCaption, ShowText, Width, Height, StretchMode, FontName, FontSize)
CreatePNG(Filename, BarcodeType, BarcodeCaption, ShowText, Width, Height, StretchMode, FontName, FontSize)
GetPNGStream (BarcodeType, Caption, ShowText, Width, Height, StretchMode, FontName, FontSize)
Here’s VBScript example:
Dim bc
Set bc=CreateObject("BarcodeX.CBarcodeX.1"
bc.CreateBMP "c:\bcx.bmp",0,"1234567890",1,200,100,1,"Arial",12
bc.CreatePNG "c:\bcx.png",0,"1234567890",1,200,100,1,"Arial",12
or, for out-of-memory streaming
<%
dim bc
set bc=Server.CreateObject("BarcodeX.CBarcodeX.1"
Response.ContentyType="image/png"
Response.BinaryWrite bc.GetPNGStream(0,"123123123",1,320,240,0,"Arial",20)
set bc = Nothing
%>
....and...
Methods:
a) Copy() method
Copy a barcode picture to the clipboard in metafile format.
Syntax: object.Copy
Remarks: Use this method to copy barcode to the clipboard and use Edit->Paste command in your application to paste barcode. Barcode is in vector format, so you can resize it without losing quality.
b) CreateBMP() method
Creates a windows bitmap (.BMP) graphics file of barcode on a disk.
Syntax: object.CreateBMP(Filename as String, Width As Long, Height As Long)
Remarks: Filename should have an .BMP extension.
Width and height parameters are in device pixels.
c) PaintAt(hDC,x,y,w,h) method
Draw a barcode to a device context.
Syntax: object.PaintAt(hDc, left, top, width, height)
The PaintAt syntax has these parts:
...
object An object expression that evaluates to a BarcodeX control.
hDc A numeric expression that determines the device context's handle where the barcode will be painted.
...
Remarks: The left, top, width and height parameters are in pixels. You can use the Screen.TwipsPerPixelX and Screen.TwipsPerPixelY or Printer.TwipsPerPixelX to convert from Visual Basic's twips to device coordinates.
Visual Basic code...
Printer.Print "" 'initialize printer
BarcodeX1.PaintAt(Printer.hDC,500,500,3000,2000) 'paint barcode on printer
Printer.EndDoc 'close printer document
... will print barcode on default printer.
----------
The above code obviously does NOT work from within an outlook form as it is VB, not VBA....
Please help me
Oliver Rosenkranz
o.rosenkranz@estensis.de
I am in desperate need of some advise and help from more experienced folk than me.
I am currently implementing a custom Outlook contact form that will contain a BarCode label object (BarcodeX from FathSoft). The object itself has already been integrated into the outlook form and works pretty well. Now, my plan was/is to place a custom button below that object and add some VBA code to its Click event routine. It should print the Barcode object itself either on the default windows printer or on a specifiable network printer (whatever is most easy to achieve).
Is there a way to achieve printing that single object or a bitmap graphic which has beend created from it?
Could you help me coding that (because I am totally new to this mess)?
I can imagine you are not that familiar with BarcodeX (neither am I). BarcodeX objects are activeX components which support certain methods (not sure about VBA though):
-------------
Here's what BarcodeX help file is saying:
ASP & scripting
BarcodeX control has COM interface “CbarcodeX” and it has these methods;
CreateBMP(Filename, BarcodeType, BarcodeCaption, ShowText, Width, Height, StretchMode, FontName, FontSize)
CreatePNG(Filename, BarcodeType, BarcodeCaption, ShowText, Width, Height, StretchMode, FontName, FontSize)
GetPNGStream (BarcodeType, Caption, ShowText, Width, Height, StretchMode, FontName, FontSize)
Here’s VBScript example:
Dim bc
Set bc=CreateObject("BarcodeX.CBarcodeX.1"
bc.CreateBMP "c:\bcx.bmp",0,"1234567890",1,200,100,1,"Arial",12
bc.CreatePNG "c:\bcx.png",0,"1234567890",1,200,100,1,"Arial",12
or, for out-of-memory streaming
<%
dim bc
set bc=Server.CreateObject("BarcodeX.CBarcodeX.1"
Response.ContentyType="image/png"
Response.BinaryWrite bc.GetPNGStream(0,"123123123",1,320,240,0,"Arial",20)
set bc = Nothing
%>
....and...
Methods:
a) Copy() method
Copy a barcode picture to the clipboard in metafile format.
Syntax: object.Copy
Remarks: Use this method to copy barcode to the clipboard and use Edit->Paste command in your application to paste barcode. Barcode is in vector format, so you can resize it without losing quality.
b) CreateBMP() method
Creates a windows bitmap (.BMP) graphics file of barcode on a disk.
Syntax: object.CreateBMP(Filename as String, Width As Long, Height As Long)
Remarks: Filename should have an .BMP extension.
Width and height parameters are in device pixels.
c) PaintAt(hDC,x,y,w,h) method
Draw a barcode to a device context.
Syntax: object.PaintAt(hDc, left, top, width, height)
The PaintAt syntax has these parts:
...
object An object expression that evaluates to a BarcodeX control.
hDc A numeric expression that determines the device context's handle where the barcode will be painted.
...
Remarks: The left, top, width and height parameters are in pixels. You can use the Screen.TwipsPerPixelX and Screen.TwipsPerPixelY or Printer.TwipsPerPixelX to convert from Visual Basic's twips to device coordinates.
Visual Basic code...
Printer.Print "" 'initialize printer
BarcodeX1.PaintAt(Printer.hDC,500,500,3000,2000) 'paint barcode on printer
Printer.EndDoc 'close printer document
... will print barcode on default printer.
----------
The above code obviously does NOT work from within an outlook form as it is VB, not VBA....
Please help me
Oliver Rosenkranz
o.rosenkranz@estensis.de