Copy past problem

N

Naz

Hi all

I have a Word macro to compile a report by opening Excel worksheets and
copying pre-defined ranges to the document. I use a standard Dell machine
with Office XP locally installed and it works fine.
However, my colleague who actually need to run the report use terminal
machines, i.e. Office XP runing on the server.
When they run the report it gets half way through and throws up this error

c:\exceldoc\ caused a problem. Command failed.

On my PC i only get this problem if i run the macro more than once. In which
case i restart Word and it will work.
So to me it appears as if it is either a clipboard or memory problem.

I have tried to find ways of clearing the clipboard using VBA but apparently
its not possible. I found this snippet of could which is suppose to be the
equivalent of click the clear clipboard button, but have no idea how to use
it. I keep get block not defined type of errors.

Application.CommandBars.FindControl(ID:=3634).Execute




All help is appreciated.

__________________
Naz
London
 
J

Jean-Guy Marcil

Naz was telling us:
Naz nous racontait que :
Hi all

I have a Word macro to compile a report by opening Excel worksheets
and copying pre-defined ranges to the document. I use a standard Dell
machine with Office XP locally installed and it works fine.
However, my colleague who actually need to run the report use terminal
machines, i.e. Office XP runing on the server.
When they run the report it gets half way through and throws up this
error

c:\exceldoc\ caused a problem. Command failed.

On my PC i only get this problem if i run the macro more than once.
In which case i restart Word and it will work.
So to me it appears as if it is either a clipboard or memory problem.

I have tried to find ways of clearing the clipboard using VBA but
apparently its not possible. I found this snippet of could which is
suppose to be the equivalent of click the clear clipboard button, but
have no idea how to use it. I keep get block not defined type of
errors.

Application.CommandBars.FindControl(ID:=3634).Execute

I believe that the above clears the Office clipboard, which is a totally
different thing from the Windows Clipboard, which is what you are probably
using in your code.

However, you state that you can see this error on your machine if you run
the code a second time.

A well built macro should not exhibit this problem when run a second time.
I would investigate why the problem occurs on your machine when you run the
code twice, try to fix that problem, and then see if that does not fix the
"other machine" problem as well.
 
N

Naz

Hi

I have tried debugging the code on my machine but can't figure it out.
The problem occurs with any code that copies from excel to word, even the
most basic, on the the term machines 10 seems to the max number of copy and
pastes, on mine it seems to be 24.

How do i clear the windows clipboard?

Naz
 
J

Jean-Guy Marcil

Naz was telling us:
Naz nous racontait que :
Hi

I have tried debugging the code on my machine but can't figure it out.
The problem occurs with any code that copies from excel to word, even
the most basic, on the the term machines 10 seems to the max number
of copy and pastes, on mine it seems to be 24.

If your code is not too involved, posting it might give us a chance to see
if anything is wrong with it.
How do I clear the windows clipboard?

Normally, all you need to do is replace the content with a small amount,
something like:

ActiveDocument.Range(0,1).Copy

Or, check out the following page, it is An Excel page, but the Windows
clipboard is the same in all applications:

http://www.cpearson.com/excel/Clipboard.aspx
 

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