|
-
Feb 22nd, 2002, 04:34 PM
#1
Thread Starter
Addicted Member
Tricky MS Word interacting with VB App question
Is there a way of keeping track of content copied from a Word document into a RTB on a VB Form?
I am creating an application where the user clicks on a Command Button which then populates a RTB with the content from the MS Word document.
I need the user to then be able to highlight a section of text within the RTB, click a 'Covert Text to Heading1' button and then see the same text within the Word document converted to the Heading1 style.
I have been trying for ages to get something going, but am having difficulty relating what is selected in the RTB to the same text in the Word document.
Any ideas would be much appreciated 
Thanks,
Chris
-
Feb 22nd, 2002, 07:28 PM
#2
Thread Starter
Addicted Member
Anybody?? Please!!!
-
Feb 22nd, 2002, 09:05 PM
#3
You have the whole document text in the RTB, right? Then it would be something like this:
VB Code:
Dim MyRange As Range
'Start of range = RichTextBox1.SelStart
'End of Range = RichTextBox1.SelStart + RichTextBox1.SelLength
Set MyRange = ActiveDocument.Range(RichTextBox1.SelStart, RichTextBox1.SelStart + RichTextBox1.SelLength)
MyRange.Select
'To use Word constant styles
Selection.Style = -2 'wdStyleHeading1 constant
'or to use the styles associated with a document
'Selection.Style = ActiveDocument.Styles("Heading 1")
That matches the RTB selection range to the Word document range. You probably don't need to use a range. I guess you could do this:
VB Code:
ActiveDocument.Range(RichTextBox1.SelStart, RichTextBox1.SelStart + RichTextBox1.SelLength).Select
Selection.Style = -2 'wdStyleHeading1 constant
-
Feb 23rd, 2002, 11:04 AM
#4
Thread Starter
Addicted Member
Thanks! I'll give it a go
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
|