Specify open/default folder from memory scrap

P

Paul

I am using Word 2000 and trying to do a macro where I can
paste from memory a part of the directory path. In other
words instead of:
ChangeFileOpenDirectory "f:\estates\99999"

I want something like:
ChangeFileOpenDirectory "f:\estates\[paste memory
here]"
(Where I had previously copy "45634" into memory.)
The reason for this being the need to open Word every
time in a different subfolder of "f:\estates\" All
documents created during an open session are to be saved
in that subfolder.
 
J

Jezebel

I assume by 'memory' you mean the clipboard. Can't be done directly in VBA
because (unlike VB) you don't have direct access to the clipboard object.
One work-around is to paste it into a document and retrieve it that way:

Dim pPath as string

With Documents.Add
.Content.Paste
pPath = .Content
.Close SaveChanges:=False
End with

pPath = "f:\estates\" & Left$(pPath, len(pPath)-1) 'Discard the
trailing CR
ChangeFileOpenDirectory pPath
 
J

Jonathan West

Jezebel said:
I assume by 'memory' you mean the clipboard. Can't be done directly in VBA
because (unlike VB) you don't have direct access to the clipboard object.

Karl Peterson has helpully solved that problem with a Clipboard class that
replicates the VB Clipboard object.

Take a look at the following page

http://www.mvps.org/vb/samples.htm

and scroll down until you come to the ClipEx.zip sample


The ClipEx class allows you to extract text from the clipboard and place
text into it, and perform just about all the functions of VB's Clipboard
object.
 

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