|
-
Jul 25th, 2008, 03:25 AM
#1
Thread Starter
Addicted Member
Strange Clipboard Response
i cannot understand what is happening, and i need to solve the problem.
the following snippet of code is used six times in the programme
Code:
ExcelFile.Worksheets("Calculations").Range(CellAdres).Activate
Clipboard.Clear
ExcelFile.Worksheets("Calculations").Range(CellAdres).Copy
WordObj.ActiveDocument.Tables(i).Rows(j).Cells(k).Range.Paste
the programme may run once, or even twice, successfully, but at some time it hangs and advises:
"This method or property is not available because the clipboard is empty or not valid"
using the debugger i know this happens in different parts of the programme, but always in the above snippet.
the curious thing is that it only happens on my desktop in my office, not on my laptop.
can anyone help me please?
john
-
Jul 25th, 2008, 05:25 AM
#2
Re: Strange Clipboard Response
is the clipboard empty because there is nothing in the range to copy?
as the clipboard is cleared immediately before it is unlikely to be not valid
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jul 25th, 2008, 07:18 AM
#3
Thread Starter
Addicted Member
Re: Strange Clipboard Response
westconn1,
no, when i look at the Excel cell, it contains information and is highlighted in the usual manner that excel uses when copying.
i added the "clear" prior to it copying because at first i thought maybe it was getting too full, but that obviously wasn't the case.
do you have nay other ideas, i am completely baffled?
regards,
john
-
Jul 25th, 2008, 07:56 AM
#4
Re: Strange Clipboard Response
 Originally Posted by johnmtb
the curious thing is that it only happens on my desktop in my office, not on my laptop.
What do you have running on your desktop, but not on your laptop, that might be accessing, and thus clearing, the clipboard?
-
Jul 26th, 2008, 01:43 AM
#5
Thread Starter
Addicted Member
Re: Strange Clipboard Response
Hack,
it is difficult to say, it is the company computer, and they often do things behind the scenes that we are not aware of. at the moment i am working in Nigeria, and the whole system is controlled from Houston.
but i have noticed that sometimes when i copy from one place to paste later that the clipboard is empty!
do you have any suggestions what may be casuing such a problem, and i can arrange for our IT guy to remedy the problem.
regards,
john
-
Jul 26th, 2008, 06:51 AM
#6
Re: Strange Clipboard Response
If something else is hammering the clipboard on your works computer I guess it might be a tricky thing to change.
Accessing WordObj.ActiveDocument.Tables(i).Rows(j).Cells(k).Range is probably not super fast. You could perhaps speed up the copy/paste process by using intermediary variables and/or a with statement. You could also verify the data before pasting, if it's not right try again. I'm not big on excel but when I tried copying a range manually I noticed it copies lots of data in a range of formats (DDE link, Text, Rtf, Bitmap, Metafile, EMetaFile and DIB ) that can't be that fast.
Also is there a way to copy the range directly without using the clipboard?
-
Jul 26th, 2008, 09:05 AM
#7
Re: Strange Clipboard Response
I suspect the following code (which doesn't use the clipboard) will do the same as the original code:
Code:
WordObj.ActiveDocument.Tables(i).Rows(j).Cells(k).Range = ExcelFile.Worksheets("Calculations").Range
-
Jul 26th, 2008, 09:20 AM
#8
Thread Starter
Addicted Member
Re: Strange Clipboard Response
si the geek,
thank you, i will try that.
regards,
john
-
Jul 26th, 2008, 10:33 AM
#9
Thread Starter
Addicted Member
Re: Strange Clipboard Response
si the geek,
i tried your suggestion, with a little modification, i had to add (CellAdres) after the word range and it worked fine. however, that created another problem, the number format was lost, and numbers such as 1,234,567.00, came out as 1234567.00, and i cannot find out how to format numbers in Word tables.
can you help with this please?
regards,
john
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|