Problem with clipboard macro

B

Brian Holfield

From docA I first clip TextA to the Offfice Clipboard, then I clip
TextB to it.
In docB I record Mymacro with these actions: First I create a table of
one row and two columns. Then I open the clipboard, then paste TextB
into the first cell of the table, then delete TextB from the clipboard.
Now I paste TextA from the open clipboard into the second cell of the
table, and then delete TextA from the clipboard. Now I close the
clipboard.

When I next have a new TextA and Text B on the clipboard I run Mymacro.
It pastes TextB two times and leaves TextA and TextB on the clipboard.

Any way to get the macro to do what I need, that is paste TextB then
TextA and delete them from the clipboard?
 
H

Helmut Weber

Hi Brian,

have a look at the code you recorded.
There is probably no trace of anything like clipboard in it.

As nobody else has answered so far,
I dare to suppose, the office clipboard is not accessible
programmatically, except that "paste" pastes items
from the office clipboard in the reverse order they
appear in the clipboard window.

Applies to Word 2003,
I don't know about Office 12.

If I am wrong, somebody will correct me.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
T

Tony Jollans

If I am wrong, somebody will correct me

LOL - If only Paste _would_ paste from the Office Clipboard life would be
easier. Paste always pastes from the Windows Clipboard.

Brian,

As you talks of selectively deleting office clipboard entries you must have
Word 2002 or 2003. In these versions there is, as far as I know, no way to
access the office clipboard entries via code and I don't think there is any
way to do what you want without using code in the copy operation as well as
the paste operation.
 
H

Helmut Weber

Hi Tony,

right you are!
Paste always pastes from the Windows Clipboard.

When I recorded "Paste all" from the office clipboard,
with 3 items in there, i got:

Selection.Paste
Selection.Paste
Selection.Paste

So I thought...

Should have tested it.

:)

Cheers

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
B

Brian Holfield

Odd that Word uses Windows clipboard when it has its own clipboard, but
that's the way it is.

Is there a way around this by clipping TextA in variableA and TextB
into variableB? Seems possible to me, but I'm too green a user to be
able to do it.
 
H

Helmut Weber

Hi Brian,
Is there a way around this by clipping TextA in variableA and TextB
into variableB? Seems possible to me, but I'm too green a user to be
able to do it.

sure. You may put TextA into a docvariable TextA, etc.
and preserve all for later use, with loosing formatting.

Or you may use autotext entries,
which seems to me the best solution for your task.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
T

Tony Jollans

As I said before there, you will need some sort of code in the copy
operation(s). With code there are several ways to do it but the most obvious
way of interacting with the facility Microsoft have created for just this
purpose isn't available - I really don't know why, it's just, as you say,
the way it is.
 

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