Copy the path of the currently open file into the clipboard

A

andreas

Dear Experts:

I would like to copy the path of the currently open file into the
clipboard using VBA, e.g. C:\test\MyDocument.doc.

I hope this is feasible.

Thank you very much in advance for your valuable help.

Regards, Andreas
 
A

andreas

What do you want to do with it when you have it on the clipboard?

--
Hope this helps,

Doug Robbins - Word MVP
dkr[atsymbol]mvps[dot]org




Dear Experts:
I would like to copy the path of the currently open file into the
clipboard using VBA, e.g. C:\test\MyDocument.doc.
I hope this is feasible.
Thank you very much in advance for your valuable help.
Regards, Andreas- Hide quoted text -

- Show quoted text -

Hi Doug,

thank you very much for your swift reply. I would like to paste the
string anywhere, such as a Word, Excel or PowerPoint document.

Thank you.

Regards, Andreas
 
J

Jay Freedman

What do you want to do with it when you have it on the clipboard?

--
Hope this helps,

Doug Robbins - Word MVP
dkr[atsymbol]mvps[dot]org




Dear Experts:
I would like to copy the path of the currently open file into the
clipboard using VBA, e.g. C:\test\MyDocument.doc.
I hope this is feasible.
Thank you very much in advance for your valuable help.
Regards, Andreas- Hide quoted text -

- Show quoted text -

Hi Doug,

thank you very much for your swift reply. I would like to paste the
string anywhere, such as a Word, Excel or PowerPoint document.

Thank you.

Regards, Andreas

Based on the code in
http://www.word.mvps.org/FAQs/MacrosVBA/ManipulateClipboard.htm :

Sub CopyDocPath()
Dim MyData As DataObject
Dim strClip As String
strClip = ActiveDocument.FullName

Set MyData = New DataObject

MyData.SetText strClip
MyData.PutInClipboard
End Sub

In order to make this work, you MUST set a reference to the "Microsoft
Forms 2.0 Object Library" in the VBA editor by clicking Tools >
References and putting a check mark next to that item in the list.
 
A

andreas

What do you want to do with it when you have it on the clipboard?
--
Hope this helps,
Doug Robbins - Word MVP
dkr[atsymbol]mvps[dot]org

Dear Experts:
I would like to copy the path of the currently open file into the
clipboard using VBA, e.g. C:\test\MyDocument.doc.
I hope this is feasible.
Thank you very much in advance for your valuable help.
Regards, Andreas- Hide quoted text -
- Show quoted text -
thank you very much for your swift reply. I would like to paste the
string anywhere, such as a Word, Excel or PowerPoint document.
Thank you.
Regards, Andreas

Based on the code inhttp://www.word.mvps.org/FAQs/MacrosVBA/ManipulateClipboard.htm:

Sub CopyDocPath()
Dim MyData As DataObject
Dim strClip As String
strClip = ActiveDocument.FullName

Set MyData = New DataObject

MyData.SetText strClip
MyData.PutInClipboard
End Sub

In order to make this work, you MUST set a reference to the "Microsoft
Forms 2.0 Object Library" in the VBA editor by clicking Tools >
References and putting a check mark next to that item in the list.

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ:http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroupso all may benefit.- Zitierten Text ausblenden -

- Zitierten Text anzeigen -

Hi Jay,

works great. Thank you very much for your great help.

Regards, Andreas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top