Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
I wish to copy a section of a document (designated by a bookmark) to a variable. I have tried:
myString = ActiveDocument.Bookmarks("myBookmark").Range.Text This works fine except that within the bookmarked section there are FormFields and I want myString to include whatever the FormFields are displaying (i.e. the values ActiveDocument.FormFields("myFormfield").Result). All that goes into myString from the FormField is a little square box. Is there an alternative to .Range.Text which is WYSIWYG? |
#2
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Try using the FormattedText property instead. For example, the following
test macro copies the formatted text, including fields and other data, from the range defined by the first paragraph of a document to the third paragraph of the document: Sub TestMacro() Dim r As Range Set r = ActiveDocument.Paragraphs(1).Range.FormattedText ActiveDocument.Paragraphs(3).Range.FormattedText = r End Sub -- Stefan Blom Microsoft Word MVP --------------------------------------------- "PaulBishop" wrote in message ... I wish to copy a section of a document (designated by a bookmark) to a variable. I have tried: myString = ActiveDocument.Bookmarks("myBookmark").Range.Text This works fine except that within the bookmarked section there are FormFields and I want myString to include whatever the FormFields are displaying (i.e. the values ActiveDocument.FormFields("myFormfield").Result). All that goes into myString from the FormField is a little square box. Is there an alternative to .Range.Text which is WYSIWYG? -- PaulBishop |
#3
![]() |
|||
|
|||
![]() Quote:
Paul |
#4
![]() |
|||
|
|||
![]()
The Formfield options are preserved in the variable of type Range. What I need to do next is concatenate several Range variables and strings, then put the finished assembly onto the clipboard. I have tried using the PutInClipboard method 0f a DataObject but am losing the Formfields somewhere along the way. I may do it by creating a second Document, putting the paragraphs into it as Stefan shows, finally using Selection.WholeStory, Selection.Copy to put on the clipboard, as I have used this successfully before.
Paul |
#5
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Instead of copying and pasting, you may find using the InsertFile method
helpful if you want to collect data in Word format from different files. -- Stefan Blom Microsoft Word MVP --------------------------------------------- "PaulBishop" wrote in message ... The Formfield options are preserved in the variable of type Range. What I need to do next is concatenate several Range variables and strings, then put the finished assembly onto the clipboard. I have tried using the PutInClipboard method 0f a DataObject but am losing the Formfields somewhere along the way. I may do it by creating a second Document, putting the paragraphs into it as Stefan shows, finally using Selection.WholeStory, Selection.Copy to put on the clipboard, as I have used this successfully before. Paul -- PaulBishop |
#6
![]() |
|||
|
|||
![]()
I will have to copy and paste. I need to allow the user to complete a form in Word, selecting from dropdowns in Form Fields, ticking Check Boxes. When completed, it needs to selectively assemble text to be copy and pasted into another application running in a VT100 terminal emulator. That gives you an idea how old the other application is!
Paul |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Calculating based on text expressions in formfields - Word 2003 | Microsoft Word Help | |||
Eliminate all spaces in a text string | Microsoft Word Help | |||
How to . . Select all text up to a specfied string | Microsoft Word Help | |||
How to . . Select all text up to a specfied string | Microsoft Word Help | |||
What is a Directory Text String? | Microsoft Word Help |