ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using Word Bookmarks to read Text (https://www.excelbanter.com/excel-programming/291141-using-word-bookmarks-read-text.html)

Charles

Using Word Bookmarks to read Text
 
Hi I need to collect text from a word Document and put it
in a msgbox.
I am using this code but it wont work can someone help?.

with wdApp
wdDoc.bookmarks("ProbTitle").Select
.Selection.EndKey Unit:=wdLine, Extend:=wdExtend
msgbox .Selection.Text
end with

TIA
Charles




Tom Ogilvy

Using Word Bookmarks to read Text
 
If you don't have a reference set to word, the the constants wdLine and
wdExtend are viewed as uninitialized variables with a value of zero (which
probably isn't the value intended). Either create a reference to the word
object model or hard code the probably numeric value of the constants.

--
Regards,
Tom Ogilvy

"Charles" wrote in message
...
Hi I need to collect text from a word Document and put it
in a msgbox.
I am using this code but it wont work can someone help?.

with wdApp
wdDoc.bookmarks("ProbTitle").Select
.Selection.EndKey Unit:=wdLine, Extend:=wdExtend
msgbox .Selection.Text
end with

TIA
Charles






onedaywhen

Using Word Bookmarks to read Text
 
Try:

msgbox wdDoc.bookmarks("ProbTitle").Range.Text

--

"Charles" wrote in message ...
Hi I need to collect text from a word Document and put it
in a msgbox.
I am using this code but it wont work can someone help?.

with wdApp
wdDoc.bookmarks("ProbTitle").Select
.Selection.EndKey Unit:=wdLine, Extend:=wdExtend
msgbox .Selection.Text
end with

TIA
Charles



All times are GMT +1. The time now is 01:45 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com