• Open MS Paint from command button

    Author
    Topic
    #474649

    I use a form on an Access 2007 .accdb to paste pictures from the Clipboard to an OLE Object field.

    I would like to add a command button to EITHER open the Windows Paint utility OR Windows Explorer to a specific folder in order to copy a desired picture to the Clipboard for pasting. I already have the code (below) to open an Excel spreadsheet using an API call but cannot figure out how to edit the code so it will work with MS Paint.

    Private Sub cmdSpread_Click()
    On Error GoTo Err_cmdSpread_Click

    Dim oApp As Object
    Dim oWbk As Object

    Set oApp = CreateObject(“Excel.Application”)
    Set oWbk = oApp.Workbooks.Open(“E:DocumentsDatabasesReports.xlsx”)

    oApp.Visible = True

    ‘Only XL 97 supports UserControl Property
    On Error Resume Next
    oApp.UserControl = True

    Exit_cmdSpread_Click:
    Exit Sub

    Err_cmdSpread_Click:
    MsgBox Err.Description
    Resume Exit_cmdSpread_Click

    End Sub

    … any ideas out there?

    Viewing 0 reply threads
    Author
    Replies
    • #1266164

      Your code to open Excel is using OLE Automation, but unfortunately MS Paint does not support that kind of operation. Your best bet would probably be to use a “Shell” command to start Paint. See the thread Can we Automate Paint at CodeGuru for similar discussion.

      • #1266173

        Your code to open Excel is using OLE Automation, but unfortunately MS Paint does not support that kind of operation. Your best bet would probably be to use a “Shell” command to start Paint. See the thread Can we Automate Paint at CodeGuru for similar discussion.

        Thank you for the explanation Wendell. However, what I found there is a little over my head. Was the code mentioned there VBA? I am only a beginner when it comes to writing code for Access. I usually do a lot of snip-and-fidget from other code I come across.

        It appeared to me that the solution you mentioned was for opening a FILE in Paint rather than just opening PAINT itself. I want to add photos of personnel to an already existing database. After editing the .jpg files using Photoshop, I found that the copying the results directly to the database would save the OLE as a Photoshop image and could not double-click to open unless unless Photoshop was already running. When I closed the .jpg file and then copied the image by opening it first in MS Paint, it opened fine from Access.

        I would like to save all the edited photos to a folder and then just click a command button on my form to open Paint and manually open the desired files from there for copying. I already have another button on the form to paste from the Clipboard. Do you know how to just open Paint itself rather than a specific file using Paint?

        • #1266248

          Is it possible that this is all that it takes???:
          ********************************************
          Private Sub cmdPaint_Click()
          On Error GoTo cmdPaint_Click_Err

          Shell “C:WINDOWSsystem32mspaint.exe”, vbNormalFocus

          cmdPaint_Click_Exit:
          Exit Sub

          cmdPaint_Click_Err:
          MsgBox Error$
          Resume cmdPaint_Click_Exit

          End Sub

          ********************************************

          Incredulous! Does anything need to be added for the sake of memory or other considerations?

          Also, any way of adding a line to have Paint automatically open (Ctrl+O) to a specified FOLDER (not file)?

    Viewing 0 reply threads
    Reply To: Open MS Paint from command button

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: