Consulting

Results 1 to 2 of 2

Thread: Print file using commandbutton

  1. #1

    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.

  2. #2
    VBAX Master Killian's Avatar
    Joined
    Nov 2004
    Location
    London
    Posts
    1,132
    Location
    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
  •