Results 1 to 5 of 5
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Andover, MA USA
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    copy to clipboard in Visio VBA (Visio 2003)

    I need to automate a Visio function [don't stop reading if you aren't a Visio guru <img src=/S/smile.gif border=0 alt=smile width=15 height=15> ] that requires pasting a text string from the clipboard into a dialog box that is normally completed by the user. The paste is accomplished by SendKeys but I need to get the text string to the clipboard. I've done enough research to disabuse myself of the notion that there is a simple vba command to accomplish this...but I'm hoping for suggestions of usable alternatives.

    The code below does everything except copy to clipboard.
    = = = = = = = = = = = = = =
    Sub RunXMLReport()

    Folder = ThisDocument.Path 'get folder containing current drawing
    Set doc = Visio.ActiveDocument
    DocName = doc.Name 'get name of current drawing file
    DocName = Left(DocName, Len(DocName) - 4) 'remove file extension

    FileName = Folder & DocName & " DATA.xml" 'create desired path + file name

    ' COPY FILENAME TO CLIPBOARD

    SendKeys "{Tab}" & "^(V)" 'tab into filename field and paste clipboard contents
    SendKeys "{Enter}" 'send Enter to close dialog and run report
    Visio.Addons("VisRpt").Run ("/rptDefName=C:ReportsResources.vrd /rptOutput=XML")

    End Sub
    = = = = = = = = = = = = = =

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,534
    Thanks
    3
    Thanked 147 Times in 140 Posts

    Re: copy to clipboard in Visio VBA (Visio 2003)

    You need to create an object for the specific purpose of loading text into the clipboard.
    Try digging through this <post:=28,669>post 28,669</post:> to get an understanding of the process requried.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Location
    Andover, MA USA
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: copy to clipboard in Visio VBA (Visio 2003)

    Thanks -- the post you refer to looks like exactly what I need.

    However, I get "User-defined type not defined" on the statement
    Dim MyData As DataObject

    Please forgive my relative inexperience with VBA but is there a specific type library that I need to include so DataObject is valid?

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: copy to clipboard in Visio VBA (Visio 2003)

    The DataObject is part of MSForms. If you add a UserForm to your project, this library is referenced automatically. Otherwise, you have to do it manually.

  5. #5
    Star Lounger
    Join Date
    Jan 2001
    Location
    Andover, MA USA
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: copy to clipboard in Visio VBA (Visio 2003)

    Should have been obvious but wasn't...thanks. Works wonderfully now.

Posting Permissions

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