PC Review


Reply
Thread Tools Rate Thread

Copy from Word into Excel pastes wrong picture

 
 
=?Utf-8?B?dGhlTHVnZ2FnZQ==?=
Guest
Posts: n/a
 
      23rd Apr 2007
I've got a macro that parses through a Word document and copies and pastes
tables and figures into an Excel workbook. We've got a weird intermittent
bug where the wrong picture is pasted into Excel. (We're using Office 2000.)
It's pasting the same image twice in a row, even though different images are
being copied in Word. It's almost like the clipboard hasn't had a chance to
refresh between the copy and the paste command--as if the first image is
still on the clipboard and the new one hasn't made it to the clipboard yet.

The code is in a Word Template. Here's a code snippet:

Private mobjCurrentSheet As Excel.Worksheet
Private mobjExcelApp As Excel.Application

-- there's a bunch of code that scans down the document. when it finds a
picture, it does this: --
Selection.Paragraphs(1).Range.Copy

mobjExcelApp.ActiveCell.Offset(1, 0).Activate
mobjCurrentSheet.Paste




I tried putting this for loop in between the copy and the paste, but that
didn't help.
For i = 0 To 1000
DoEvents
Next i


As I mentioned, the bug is intermittent. Most of the time it works fine,
but it happens fairly requlary. I make sure I'm not doing anything else on
the PC while my code is running, so it can't be due to me trying to do a copy
and paste operation in my email app (for example) while the macro is running
in the background.

Does anyone have any ideas? Has anyone ever seen this type of behavior
before?

Thanks in advance for the help.

 
Reply With Quote
 
 
 
 
Wei Lu [MSFT]
Guest
Posts: n/a
 
      24th Apr 2007
Hello Luggage,

I would like to suggest you clear the Windows Clipboard before you copy the
objects from word.

You could refer the following KB article in your code to clear the
clipboard:

How To Call Clipboard API from Visual Basic 4.0
http://support.microsoft.com/kb/159823

Hope this helps.

Sincerely,

Wei Lu
Microsoft Online Community Support

==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
=?Utf-8?B?dGhlTHVnZ2FnZQ==?=
Guest
Posts: n/a
 
      24th Apr 2007

Thanks.


"Wei Lu [MSFT]" wrote:

> Hello Luggage,
>
> I would like to suggest you clear the Windows Clipboard before you copy the
> objects from word.
>
> You could refer the following KB article in your code to clear the
> clipboard:
>
> How To Call Clipboard API from Visual Basic 4.0
> http://support.microsoft.com/kb/159823
>
> Hope this helps.
>
> Sincerely,
>
> Wei Lu
> Microsoft Online Community Support
>
> ==================================================
>
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
>
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: When pasting picture in Word, it pastes the frame, and no content Graham Mayor Microsoft Word Document Management 0 27th Dec 2006 03:47 PM
How do I Copy paste special picture from excel to Word 2003? =?Utf-8?B?SmltUg==?= Microsoft Word Document Management 1 22nd Dec 2005 05:59 AM
Excel macro that opens new MS Word file and pastes data as a pictu =?Utf-8?B?Um9i?= Microsoft Excel Worksheet Functions 0 6th Jul 2005 05:12 PM
When I copy text, Word pastes a print screen - not the text I copi =?Utf-8?B?Ymlzc3kx?= Microsoft Word Document Management 1 22nd Apr 2005 01:16 AM
Second picture pastes on top of first picture and seemingly erases it. Jo Shelby Microsoft Frontpage 2 26th Aug 2003 09:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:05 PM.