How to format a bookmark?

R

rrawden

I've been trying to add a format to a bookmarked name with no success. I'm
actually creating a document from the AS/400. I have a field that currently
prints like xxxxxxxxxxxxxx I want to have it displayed like this
xxx-xxxx-xxx-xxxx The bookmark is acctno. Any suggestions?
 
J

Jezebel

Word doesn't have any text formatting facility like that, it can only do
numbers; and the format you want is not numeric.
 
D

Doug Robbins

Use the following code:

Dim accountnum As Range, Account As String
With ActiveDocument
Set accountnum = .Bookmarks("AcctNo").Range
Account = .Bookmarks("AcctNo").Range.Text
accountnum.Text = Left(Account, 3) & "-" & Mid(Account, 4, 4) & "-" &
Mid(Account, 8, 3) & "-" & Right(Account, 4)
.Bookmarks.Add Name:="AcctNo", Range:=accountnum
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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

Top