|
-
Jul 2nd, 2002, 03:16 AM
#1
Thread Starter
New Member
VB ClipBoard
Hi Guys,
Using Word macro written in VB, a menu item in Word calls a macro that adds start and close index tags around the text selection (e.g. <sx1001>supposed-selection</sx1001>)
However, I would like the index code (i.e. 1001) to be copied to the clipboard to allow pasting in another program. Is this possible? as I've tried clipboard commands and have not got any result <- newbie to VB!
My sample code is below:
---------------------------------
Sub Index()
On Error Resume Next
If Selection.Range <> "" Then
indexcode = Selection.Range.Start
Selection.Range.InsertBefore Text:=">"
Selection.Range.InsertBefore Text:=indexcode
Selection.Range.InsertBefore Text:="<sx"
Selection.Range.InsertAfter Text:=">"
Selection.Range.InsertAfter Text:=indexcode
Selection.Range.InsertAfter Text:="</sx"
Selection.MoveLeft unit:=wdCharacter, Count:=1
Selection.MoveRight unit:=wdCharacter, Count:=3, Extend:=wdExtend
Selection.MoveRight unit:=wdCharacter, Count:=1
'COPY INDEXCODE
ClipBoard.Clear
If Err.Number Then
Err.Raise iCB_CLEAR_ERR, "CApplication", "Could not clear clipboard."
Else
ClipBoard.SetText indexcode
If Err.Number Then
Err.Raise iCB_SET_ERR, "CApplication", "Could not set text from active control to clipboard."
End If
End If
'PASTE INDEXCODE
Screen.ActiveControl.SelText = ClipBoard.GetText()
If Err.Number Then
Err.Raise iCB_PASTE_ERR, "CApplication", "Could not paste text from clipboard to active control."
End If
Else:
' Do Nothing
End If
End Sub
----------------------------
I am using VB ver6
Any help would be greatly appreciated!!!
/Leon
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
|