-
Solved: Printing a *.gif file from a command button depending a cell value
Hi Everyone
This is my 1st post & have recently just joined VBAX, i am a bit of a newbie to vba and would be gratefull for some help.
I am working on a excel spread sheet and would like to print a *.gif file image when a user selects a command button on a sheet, depending on what value for example cell J5 holds to what picture is printed.
I have searched all the various forums but have not found anything to actually print a gif file using vba ?
Any help would be most appreciated.
-
Welcome to the forum!
An easy way is to insert it to a sheet and print it, then delete it. An example recording it.
[VBA] Sheets("Sheet2").Select
ActiveSheet.Pictures.Insert( _
"C:\Documents and Settings\Ken\My Documents\My Pictures\Ken.jpg").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
Selection.Delete
Sheets("Sheet1").Select[/VBA]
-
Thanks Ken
I will try it tonight and let you know.
-
Thanks Ken
Sorry for the delay have been away for Easter.
That works ok, is there any other way that this can be done without showing the 2 sheet for example when a user hits the print command box it will just print the picture without displaying the 2 sheet & picture or is it possible to just hide it ?
-
[VBA] Dim sPic As String, pObj As Object
Application.ScreenUpdating = False
sPic = "x:\pics\Ken.jpg"
With Worksheets("Sheet2")
Set pObj = .Pictures.Insert(sPic)
.PrintOut Copies:=1, Collate:=True
pObj.Delete
End With
Application.ScreenUpdating = True[/VBA]
-
Printing Picture from a command button
Hi Ken,
What can i say your an absolute genius, thats exactly what i was looking for. Thankyou for your time and help
Rob
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules