Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Sep 2006
    Location
    Jhongli, Taiwan
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Open MS Paint from command button

    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:\Documents\Databases\Report s.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?

  2. #2
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts
    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.
    Wendell

  3. #3
    Lounger
    Join Date
    Sep 2006
    Location
    Jhongli, Taiwan
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by WendellB View Post
    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?

  4. #4
    Lounger
    Join Date
    Sep 2006
    Location
    Jhongli, Taiwan
    Posts
    42
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Is it possible that this is all that it takes???:
    ********************************************
    Private Sub cmdPaint_Click()
    On Error GoTo cmdPaint_Click_Err

    Shell "C:\WINDOWS\system32\mspaint.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)?
    Last edited by bradym; 2011-02-06 at 08:10.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •