T
theLuggage
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.
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.