copy file name and folder name to clipboard

Hi!
I'm looking for an easy way to copy the filename and folder (location) of an open document to the clipboard, (ideally from the save as box)
Can anyone help?
LVL 10
etech0Asked:
Who is Participating?
 
etech0Author Commented:
Thanks for all your help. I figured it out, though...

Sub getname()
Dim cltxt As DataObject
Set cltxt = New DataObject
Dim txt As String
txt = Right(ActiveDocument.Path, Len(ActiveDocument.Path) - InStrRev(ActiveDocument.Path, "\")) & _
 " - " & Left(ActiveDocument.Name, Len(ActiveDocument.Name) - InStrRev(ActiveDocument.Name, "."))
cltxt.SetText (txt)
cltxt.PutInClipboard
End Sub
0
 
GovvyCommented:
Openfiles | clip
0
 
etech0Author Commented:
can you be more specific?
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
GovvyCommented:
From command prompt type >openfiles /query
0
 
etech0Author Commented:
'openfiles' is not recognized as an internal or external command, operable program, or batch file

(I'm using windows xp - if it makes a difference)
0
 
GovvyCommented:
It should be available in XP: http://technet.microsoft.com/en-us/library/bb490961.aspx

Type 'help' at command prompt and check if it is in the list...
0
 
etech0Author Commented:
The link led to the same problem, and I don't see a solution on the 'help' list
0
 
GovvyCommented:
I meant run the help command to see if the openfiles tool is listed on your system...
0
 
etech0Author Commented:
Thanks.
I did, and it's not.
any other ideas?
0
 
Spike99On-Site IT TechnicianCommented:
Which version of Word is it?

In Office 2010, you can click on File > Info to see the full path of the file. Single click to highlight the full path & then you can copy/paste.

In Office 2007, click on the round Office logo button > Prepare > Properties.  The full path is at the top of the window.  Either double click the path to highlight it or  single click, then CNTRL+SHIFT+Arrow keys to highlight the entire path..

In Office 2003, click on View > Toolbars > Web to enable the web toolbar. Single click on the path to highlight, then copy it.

Alicia
0
 
etech0Author Commented:
Spike99: Thanks for your help. However, I'm looking for a solution that would save me time. These ideas take longer than it would take me to just retype the folder name, and copy the filename from the save as dialog box.
Maybe a macro would be able to copy the folder name and filename? (I don't want the whole path, just the folder that the file is in.)
Thanks
0
 
GrahamSkanRetiredCommented:
To run this macro,you need a reference to the Microsoft Forms 2.0 Object library. This will already be set if you have a userform in the template
Sub ToClipboard()
    Dim fld As Field
    Dim dob As New DataObject
    'dob.SetText ActiveDocument.FullName
    'dob.SetText ActiveDocument.Path
    dob.PutInClipboard
End Sub

Open in new window

0
 
etech0Author Commented:
"To run this macro,you need a reference to the Microsoft Forms 2.0 Object library"
How do I do this?
0
 
etech0Author Commented:
I figured it out myself.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.