|
|
||||||
|
#1
|
|
|
|
|
I have a old wordbasic code that I am converting to VSTO
what is equivalent of Word 97 (WordBasic) code WordBasic.SelectCurWord in VSTO Tried several alternatives wordApp.Selection.Words.Item(1).Select() OR WordRange.Words.Item(1).Select() but it picks up an extra space while WordBasic.SelectCurWord does not Here is my situation, following line in my word doc I represents a bookmark. I am at the bookmark position wordApp.Selection.Words.Item(1).Select() an extra space (including a space and reaches upto beginning of word excess) As it respects the Limit of Liability $ I_______________ excess of $ _______________ , it is also ,tried this WordApp.Selection.Expand(Word.WdUnits.wdWord) but it still includes an extra space |
|
|
|
#2
|
|
|
|
|
Declare a Range object, Set it to the word that you want to capture and then
use [RangeObject].End = [RangeObject].End - 1 |
|
#3
|
|
|
|
|
It does not work, I have to select a bookmark named bookmark1 (in my
document it takes me to the beginning of the underline) here is my code WordRange = WordDoc.GoTo(What:=Word.WdGoToItem.wdGoToBookmark, Name:="bookmark1") WordRange.Words.Item(1).Select() WordRange.End = WordRange.End - 1 |
|
#4
|
|
|
|
|
c_shah wrote:
> It does not work, I have to select a bookmark named bookmark1 (in my > document it takes me to the beginning of the underline) here is my > code > > WordRange = WordDoc.GoTo(What:=Word.WdGoToItem.wdGoToBookmark, > Name:="bookmark1") > WordRange.Words.Item(1).Select() > > WordRange.End = WordRange.End - 1 If you already have a bookmark there, you don't need all this fooling around. Just write Set WordRange = WordDoc.Bookmarks("bookmark1").Range and start working with the range. If for some reason you really need to select it so the user can do something there, you can follow that with WordRange.Select but ask yourself whether that's really necessary. |
|
#5
|
|
|
|
|
Aside from what Jay has said, you would need to modify the range before you
select it for the modification to be applied to the selection. |
|
#6
|
|
|
|
|
Ah, guilty as charged -- I didn't read the first post in the thread. If my
assumption is correct that the lines are underscore characters rather than underlined space characters, then this should do: Dim myRange As Range Set myRange = ActiveDocument.Bookmarks("bookmark1").Range myRange.MoveEndWhile Cset:="_", Count:=wdForward ' if necessary, now execute myRange.Select |
|
|
| Similar Threads | |
| what is the equivalent of this WordBasic code in VBA I'm getting wrong values for the variables for the month in this snippet of codes. This is WordBasic code and when I open the program program in word 2007 on a different... |
|
| What is the VBA equivalent of "WordBasic.ShowFormatting"? I think I've seen the answer to that question elsewhere, but danged if I can find it today. I'm trying to turn off the display of the formatting balloons that's set using... |
|
| WordBasic Here's one for the "old timers": I don't write many scripts but can usually blunder my way thru if I can find an example similar to what I want to do. I am learning... |
|
| WordBasic Although a proficient Word user I'm new to WordBasic. Here's what I need - is it unrealistic? - and can you direct me to a more appropriate site if necessary. 1. An autoopen... |
|
| WordBasic and c# Hi, I'm tring to call the DisableAutoMacros method (well I think it's a method) of the Word.WordBasic object. This is returned as a _ComObject so I can not access this... |
|
|
All times are GMT. The time now is 07:08 AM. | Privacy Policy
|