ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Print clipboard Contens (https://www.excelbanter.com/excel-programming/420828-print-clipboard-contens.html)

vqthomf

Print clipboard Contens
 
I have a tif image that I copy and load into a form to view, I would like to
print it how can I send this copied info to the printer?.
Any help will be much appreciated.
Regards
Charles

JLGWhiz

Print clipboard Contens
 
I don't know if this snippet from Chip Pearson is what you need or not.

Set a reference to the MSForms 2.0 library, and use code like the
following:


Dim DObj As MSForms.DataObject
Dim S As String
Set DObj = New MSForms.DataObject
DObj.GetFromClipboard
S = DObj.GetText
Debug.Print S


"vqthomf" wrote:

I have a tif image that I copy and load into a form to view, I would like to
print it how can I send this copied info to the printer?.
Any help will be much appreciated.
Regards
Charles


Peter T

Print clipboard Contens
 
One way would be to copy the image to an image control on an otherwise empty
sheet and print the sheet.

Following adds an image control to Sheet1 (if it doesn't already exist) and
copies the picture from the image control on the form.

I haven't included code to print the sheet but you can adapt that from a
recorded macro. First you may want to check things like picture size and
stretch properties, border, etc.

Private Sub CommandButton1_Click()
Dim ole As OLEObject
Dim ws As Worksheet
Dim img As Image

Set ws = Worksheets("Sheet1") ' < some empty sheet
On Error Resume Next
Set img = ws.OLEObjects("imgPrint")
On Error GoTo 0

If ole Is Nothing Then
Set ole = ws.OLEObjects.Add("forms.image.1")
ole.Name = "imgPrint"
End If
ole.Visible = True

Set img = Me.Image1 ' < change to suit

Set ole.Object.Picture = img.Picture

With ole
.Left = 0
.Top = 0
.Object.AutoSize = True
End With

End Sub

Regards,
Peter T


"vqthomf" wrote in message
...
I have a tif image that I copy and load into a form to view, I would like
to
print it how can I send this copied info to the printer?.
Any help will be much appreciated.
Regards
Charles





All times are GMT +1. The time now is 02:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com