Results 1 to 5 of 5
  1. #1
    New Lounger
    Join Date
    Jan 2002
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Put Excel Worksheet name in Clipboard (EXCEL 2000 ver 9.0.4402 SR-1)

    I have a macro in WORD that allows the user to click a toolbar icon and the entire document name and path is placed in the clipboard. the vb code that accomplishes the is :
    Sub PutInClipBoard()

    Dim datFileName As DataObject
    Dim strfullname As String

    Set datFileName = New DataObject
    strfullname = ActiveDocument.FullName
    datFileName.SetText strfullname
    datFileName.PutInClipBoard

    End Sub

    I want to do the same thing in EXCEL . Is this possible? If so, how?
    Thanks

  2. #2
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    2,815
    Thanks
    132
    Thanked 480 Times in 457 Posts

    Re: Put Excel Worksheet name in Clipboard (EXCEL 2000 ver 9.0.4402 SR-1)

    When you copy a cell in Excel the contents are copied to the clipboard as far as I am aware.

    So, in your VBA code use something like
    [a1] = ActiveWorkbook.Fullname 'to write the required info to a cell

    ...and then use
    [a1].Copy 'copies info to clipboard


    zeddy

  3. #3
    New Lounger
    Join Date
    Jan 2002
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Put Excel Worksheet name in Clipboard (EXCEL 2000 ver 9.0.4402 SR-1)

    Thanks. Tried the suggested code and it works just fine.

  4. #4
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Brussels, Brussel, Belgium
    Posts
    159
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Put Excel Worksheet name in Clipboard (EXCEL 2000 ver 9.0.4402 SR-1)

    you can use exactly the same code as in your first post, using the dataobject that is. because this is an object that belongs to the userforms object hierarchy, you need to set a reference to microst forms 2.0 object library from the tools->references menu in the vbe. if you can't find the reference, simply insert a userform causing the reference to be added automatically, then delete the userform, the reference will stay and your code will run fine.

  5. #5
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    199
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Re: Put Excel Worksheet name in Clipboard (EXCEL 2000 ver 9.0.4402 SR-1)

    Hi,

    I tried this macro in both Word and Excel and found there is a slight mod required to get it to run in Excel.

    ActiveDocument needs to be changed to ActiveWorkbook.

    Regards,

    Peter Moran
    Two heads are always better than one!

Posting Permissions

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