Results 1 to 11 of 11
  1. #1
    omahadivision is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    21

    Macro/module to paste into an OLE object?

    Hello!

    I am new here but I've been reading a lot of old articles as I build my database.



    I have a fairly simple question that I can't seem to find an answer to. I have a form with an OLE object, and I want to find a way to make a command button that automatically pastes whatever is on the clipboard in it instead of right-clicking and putting in paste. It seems quite simple, but I haven't found anything on it yet.

    Thanks!

    -Dave

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Maybe this has what you need http://www.cpearson.com/excel/clipboard.aspx
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    omahadivision is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    21
    Quote Originally Posted by June7 View Post
    Thanks! That has almost everything I need, except how would I specify it to paste in the OLE box from the Access side? Thanks again!

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Not sure. Never worked with the OLE controls. You want to copy/paste an image? Why?

    I think the sample code is assuming clipboard data is a string. Don't know if could modify function to handle image instead of text.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    omahadivision is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    21
    Quote Originally Posted by June7 View Post
    Not sure. Never worked with the OLE controls. You want to copy/paste an image? Why?

    I think the sample code is assuming clipboard data is a string. Don't know if could modify function to handle image instead of text.
    Basically, I have a macro that would open an excel file, copy a image, and then close it, and I'd like the graph to be pasted into my ole box on my form. I'll fiddle around more with the pasting issue.

  6. #6
    omahadivision is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    21
    I'm thinking there might be an easier way, using an OnClick sub for the box

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Regardless of the event, issue is the same. Can the code be modified to handle an image?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    omahadivision is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    21
    Quote Originally Posted by omahadivision View Post
    Basically, I have a macro that would open an excel file, copy a image, and then close it, and I'd like the graph to be pasted into my ole box on my form. I'll fiddle around more with the pasting issue.
    All right, I am almost there! I put in DoCmd.RunCommand acCmdPaste for the double-click on the OLE object! Now I just have to transfer that to a button and I'm done! This part seems easy, but I'll admit that I'm stuck. Is it easier to program a button to simulate the double-click or just link to it directly?

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    The graph pasted?

    The button Click event can call the OLE control event procedure.

    Assuming everything is on the same form.

    Sub buttonname_Click()
    Call OLEobjectName_DblClick()
    End Sub

    If that doesn't work, maybe have to just put a label above the OLE control:
    "Double click the box below to paste graph."
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  10. #10
    omahadivision is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    21
    It all works now! Evidently single click allows more things than double click. Thank you very, very much! How do I mark this as solved?

  11. #11
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    I marked solved. Option under Thread Tools at top of the thread.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Module Error in Macro
    By TimMoffy in forum Modules
    Replies: 3
    Last Post: 06-20-2012, 09:52 AM
  2. Replies: 2
    Last Post: 06-06-2011, 04:18 PM
  3. Module to be run by macro to validate
    By GraemeG in forum Modules
    Replies: 4
    Last Post: 02-26-2011, 06:26 AM
  4. Creating Macro from Module
    By Harley Guy in forum Modules
    Replies: 1
    Last Post: 11-08-2010, 07:44 AM
  5. Running module from Macro
    By Harley Guy in forum Modules
    Replies: 6
    Last Post: 10-27-2010, 11:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums