-
Print file using commandbutton
I'm not sure if this is possible, and not to worry if it isn't it's just something that would be nice to have.
I would like to have a commandbutton that when clicked prints a Jpeg image.
The file is called 'Sales form Print' and is in the same directory as the Excel workbook.
Am I hoping too much or is this a simple thing to do?
Thanks,
john.
-
I don't think it's too much to ask...
You need to set up a shell application object and give it the file and the print command.
Here's an example - bear in mind it will error if it can't find the filename but that's easily fixed if it's an issue[VBA]Sub PrintFile()
Dim objShellApp As Object
Dim objFolder As Object
Dim strFileName As String
strFileName = "Picture 1.gif"
Set objShellApp = CreateObject("Shell.Application")
Set objFolder = objShellApp.Namespace(ThisWorkbook.Path)
objFolder.ParseName(strFileName).InvokeVerb ("&Print")
End Sub[/VBA]
K :-)
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