M
MT DOJ Help Desk
Word 2000
I have a macro that passes data to and from the clipboard. I have a problem
in that the contents of the clipboard seem to be changing unexpectedly. In
the code below I've marked the lines where the change seems to happen. If I
put a watch on cbLocate and step through the code, it contains one value the
first time CheckClipboard is run, and a different value the second time
CheckClipboard runs. The subroutines below are shown in their entirety.
****************
Sub RemoveLocate()
SelectLocate <<< This calls a subroutine that just selects
text in the document.
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
next block of text in the document.
End Sub
Sub CheckClipboard()
ReadFromClipboard
If InStr(1, cbLocate, "LOCATED RECORD NOTIFICATION",
vbBinaryCompare) Or _
InStr(1, cbLocate, "$L", vbBinaryCompare) Then
PasteLocate
End If
End Sub
Sub ReadFromClipboard()
Set cbValue = New DataObject
cbValue.GetFromClipboard
cbLocate = Trim(cbValue.GetText)
End Sub
****************
As indicated above, it seems to be the Selection.Delete command that is
changing the clipboard contents. This makes a certain amount of sense if
the block of text is being cut from the document. Is there a way to delete
blocks of text without the data landing on the clipboard? Is there
something about the clipboard that I don't understand that might be causing
this problem, like maybe the clipboard is storing multiple blocks of text
and my code isn't handling that properly? Also, I understand that data
objects can hold multiple pieces of information. Could the data object be
the problem?
I apologize if this is all too vague, but I thought that trying to post my
complete set of macros, or explain the fine details of everything that I'm
doing, would be too confusing, so I've tried to boil it down to the section
of code where I'm seeing the problem (although, I know this might just be a
symptom, and the real problem might be elsewhere in my code).
Any help you can offer will be greatly appreciated.
--Tom
I have a macro that passes data to and from the clipboard. I have a problem
in that the contents of the clipboard seem to be changing unexpectedly. In
the code below I've marked the lines where the change seems to happen. If I
put a watch on cbLocate and step through the code, it contains one value the
first time CheckClipboard is run, and a different value the second time
CheckClipboard runs. The subroutines below are shown in their entirety.
****************
Sub RemoveLocate()
SelectLocate <<< This calls a subroutine that just selects
text in the document.
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
command seems to change the clipboard contents.CheckClipboard
Selection.Delete Unit:=wdCharacter, Count:=1 <<< This
NextLocate <<< This calls a subroutine that goes to theCheckClipboard
next block of text in the document.
End Sub
Sub CheckClipboard()
ReadFromClipboard
If InStr(1, cbLocate, "LOCATED RECORD NOTIFICATION",
vbBinaryCompare) Or _
InStr(1, cbLocate, "$L", vbBinaryCompare) Then
PasteLocate
End If
End Sub
Sub ReadFromClipboard()
Set cbValue = New DataObject
cbValue.GetFromClipboard
cbLocate = Trim(cbValue.GetText)
End Sub
****************
As indicated above, it seems to be the Selection.Delete command that is
changing the clipboard contents. This makes a certain amount of sense if
the block of text is being cut from the document. Is there a way to delete
blocks of text without the data landing on the clipboard? Is there
something about the clipboard that I don't understand that might be causing
this problem, like maybe the clipboard is storing multiple blocks of text
and my code isn't handling that properly? Also, I understand that data
objects can hold multiple pieces of information. Could the data object be
the problem?
I apologize if this is all too vague, but I thought that trying to post my
complete set of macros, or explain the fine details of everything that I'm
doing, would be too confusing, so I've tried to boil it down to the section
of code where I'm seeing the problem (although, I know this might just be a
symptom, and the real problem might be elsewhere in my code).
Any help you can offer will be greatly appreciated.
--Tom