Automation? Word

W

Wilson Pye

Hi,

I am trying to get the bookmark "Sales Tax" to print with a single under
line.

Here is the code:

oRange = oDocument.Range(0,0)
.InsertAfter( CR )
.InsertAfter( "Sales Tax: " + TAB )
.Collapse( wdCollapseEnd )
oDocument.Bookmarks.Add("SalesTax", oRange)

Any help on the code?


Wilson
 
J

Jonathan West

Hi Wilson

Before the collapse command, add the following line

.Underline = wdUnderlineSingle

By the way, as you have it at present, the bookmark is marking the end of
the "Sales Tax" string, not the whole string. Is that what you intended? If
not, then add the bookmark before you collapse the range.
 
W

Wilson Pye

Hi Jonathan,

Here is a snip of the code:
***
.InsertAfter( CR + CR)
.InsertAfter( "Bid: " + TAB)
.Collapse( wdCollapseEnd )
oDocument.Bookmarks.Add("Bid", oRange)

.InsertAfter( CR )
.InsertAfter( "Sales Tax: " + TAB )
.Underline = wdUnderlineSingle
.Collapse( wdCollapseEnd )
oDocument.Bookmarks.Add("SalesTax", oRange)
***
It did produce the underline for "Sales Tax: $ 62.50" however,
I only want the contents of the bookmark underlined which would be "$ 62.50".
(I am not sure if you can see the underline on the output I have enclosed?)

Bid: $ 1250.00
Sales Tax: $ 62.50
Total: $ 1312.50

Your help is very much appreciated.

Wilson
 
J

Jonathan West

OK, in that case, you need to split things up a bit, as follows

.InsertAfter( CR )
.InsertAfter( "Sales Tax: ")
.Collapse( wdCollapseEnd )
.InsertAfter( TAB )
.Underline = wdUnderlineSingle
.Collapse( wdCollapseEnd )
oDocument.Bookmarks.Add("SalesTax", oRange)


--
Regards
Jonathan West - Word MVP
http://www.multilinker.com
Please reply to the newsgroup

Hi Jonathan,

Here is a snip of the code:
***
.InsertAfter( CR + CR)
.InsertAfter( "Bid: " + TAB)
.Collapse( wdCollapseEnd )
oDocument.Bookmarks.Add("Bid", oRange)

.InsertAfter( CR )
.InsertAfter( "Sales Tax: " + TAB )
.Underline = wdUnderlineSingle
.Collapse( wdCollapseEnd )
oDocument.Bookmarks.Add("SalesTax", oRange)
***
It did produce the underline for "Sales Tax: $ 62.50" however,
I only want the contents of the bookmark underlined which would be "$
62.50".
(I am not sure if you can see the underline on the output I have
enclosed?)

Bid: $ 1250.00
Sales Tax: $ 62.50
Total: $ 1312.50

Your help is very much appreciated.

Wilson
 
W

Wilson Pye

Jonathan,

Hmm We are getting closer <s>

Bid: $ 1250.00

Sales Tax: $ 62.50

Total: _____ $ 1312.50

Can we get the underline to start at the very beginning of the book mark which is the "$"?

Wilson


OK, in that case, you need to split things up a bit, as follows

.InsertAfter( CR )
.InsertAfter( "Sales Tax: ")
.Collapse( wdCollapseEnd )
.InsertAfter( TAB )
.Underline = wdUnderlineSingle
.Collapse( wdCollapseEnd )
oDocument.Bookmarks.Add("SalesTax", oRange)


--
Regards
Jonathan West - Word MVP
http://www.multilinker.com
Please reply to the newsgroup

Hi Jonathan,

Here is a snip of the code:
***
.InsertAfter( CR + CR)
.InsertAfter( "Bid: " + TAB)
.Collapse( wdCollapseEnd )
oDocument.Bookmarks.Add("Bid", oRange)

.InsertAfter( CR )
.InsertAfter( "Sales Tax: " + TAB )
.Underline = wdUnderlineSingle
.Collapse( wdCollapseEnd )
oDocument.Bookmarks.Add("SalesTax", oRange)
***
It did produce the underline for "Sales Tax: $ 62.50" however,
I only want the contents of the bookmark underlined which would be "$ 62.50".
(I am not sure if you can see the underline on the output I have enclosed?)

Bid: $ 1250.00
Sales Tax: $ 62.50
Total: $ 1312.50

Your help is very much appreciated.

Wilson
 
J

Jonathan West

In that case, you need to break up the contents of the variable TAB and
insert it in two parts, the non underlined spaces preceding the $ sign, and
then underlined spaces after.

--
Regards
Jonathan West - Word MVP
http://www.multilinker.com
Please reply to the newsgroup

Jonathan,

Hmm We are getting closer <s>

Bid: $ 1250.00

Sales Tax: $ 62.50

Total: _____ $ 1312.50

Can we get the underline to start at the very beginning of the book mark
which is the "$"?

Wilson


OK, in that case, you need to split things up a bit, as follows

.InsertAfter( CR )
.InsertAfter( "Sales Tax: ")
.Collapse( wdCollapseEnd )
.InsertAfter( TAB )
.Underline = wdUnderlineSingle
.Collapse( wdCollapseEnd )
oDocument.Bookmarks.Add("SalesTax", oRange)


--
Regards
Jonathan West - Word MVP
http://www.multilinker.com
Please reply to the newsgroup

Hi Jonathan,

Here is a snip of the code:
***
.InsertAfter( CR + CR)
.InsertAfter( "Bid: " + TAB)
.Collapse( wdCollapseEnd )
oDocument.Bookmarks.Add("Bid", oRange)

.InsertAfter( CR )
.InsertAfter( "Sales Tax: " + TAB )
.Underline = wdUnderlineSingle
.Collapse( wdCollapseEnd )
oDocument.Bookmarks.Add("SalesTax", oRange)
***
It did produce the underline for "Sales Tax: $ 62.50"
however,
I only want the contents of the bookmark underlined which would be "$
62.50".
(I am not sure if you can see the underline on the output I have
enclosed?)

Bid: $ 1250.00
Sales Tax: $ 62.50
Total: $ 1312.50

Your help is very much appreciated.

Wilson
 
W

Wilson Pye

HI Jonathan,

Thanks for the suggestion. I tried this and it works:
.InsertAfter( CR )
.InsertAfter( "Sales Tax: " + TAB)
.Collapse( wdCollapseEnd )
.InsertAfter( TAB )
.Underline = wdUnderLineSingle
oDocument.Bookmarks.ADD("SalesTax", oRange)
.Collapse( wdCollapseEnd )

Thanks again!
In that case, you need to break up the contents of the variable TAB and insert it in two parts, the non underlined spaces preceding the $ sign, and then underlined spaces after.

--
Regards
Jonathan West - Word MVP
http://www.multilinker.com
Please reply to the newsgroup

Jonathan,

Hmm We are getting closer <s>

Bid: $ 1250.00

Sales Tax: $ 62.50

Total: _____ $ 1312.50

Can we get the underline to start at the very beginning of the book mark which is the "$"?

Wilson


OK, in that case, you need to split things up a bit, as follows

.InsertAfter( CR )
.InsertAfter( "Sales Tax: ")
.Collapse( wdCollapseEnd )
.InsertAfter( TAB )
.Underline = wdUnderlineSingle
.Collapse( wdCollapseEnd )
oDocument.Bookmarks.Add("SalesTax", oRange)


--
Regards
Jonathan West - Word MVP
http://www.multilinker.com
Please reply to the newsgroup

Hi Jonathan,

Here is a snip of the code:
***
.InsertAfter( CR + CR)
.InsertAfter( "Bid: " + TAB)
.Collapse( wdCollapseEnd )
oDocument.Bookmarks.Add("Bid", oRange)

.InsertAfter( CR )
.InsertAfter( "Sales Tax: " + TAB )
.Underline = wdUnderlineSingle
.Collapse( wdCollapseEnd )
oDocument.Bookmarks.Add("SalesTax", oRange)
***
It did produce the underline for "Sales Tax: $ 62.50" however,
I only want the contents of the bookmark underlined which would be "$ 62.50".
(I am not sure if you can see the underline on the output I have enclosed?)

Bid: $ 1250.00
Sales Tax: $ 62.50
Total: $ 1312.50

Your help is very much appreciated.

Wilson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Automation? 0
Automation ? more info 1
Automation? 0
Envelopes? 0
VB MS Word header 3
Automation of word in Access 2007 2
Show Ink Excel 0
Adding break Lines 1

Top