Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2005

Tip: Looking for answers? Try searching our database.

reducing font of a bookmark field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Charlie - 07 Jan 2005 16:15 GMT
I'd like to add some code that would check to see if the text of a bookmark
field is two lines (containing a paragraph mark) and if it is, then to reduce
the font of all those bookmarks to 10 point so it will fit in the allotted
space in my form.  Thanks, charlie
Greg - 07 Jan 2005 16:39 GMT
Charlie,

Something like:

Sub ScratchMacro()
Dim oBkm As Bookmark

For Each oBkm In ActiveDocument.Bookmarks
If InStr(oBkm.Range.Text, vbCr) Then
oBkm.Range.Font.Size = 10
 End If
 Next oBkm
End Sub
Charlie - 07 Jan 2005 21:17 GMT
Hi again, I tried this but it didn't do anything.  I have about 4 different
bookmarks in my form.  I have an AutoNew macro running which updates all
fields when I open it.  The first fields are 4 (ASK) fields which gets the
data from the user and defines the bookmarks.  then the Bookmarks are used
multiple times in the form.  The bookmark that may contain 2 lines (a return
key) is called {Location}.  I put the code you stated at the end of my
AutoNew() but it didn't change the font of any fields.  Is there something
else wrong?  I'm not sure how the field propertys works as far as preserving
style on update.  Should that be checked?  I tried it both ways but it didn't
seem to make a difference.  BTW, I'm using Office XP if that helps.  Thanks,
charlie

> Charlie,
>
[quoted text clipped - 9 lines]
>   Next oBkm
> End Sub
Greg - 07 Jan 2005 16:39 GMT
Charlie,

Something like:

Sub ScratchMacro()
Dim oBkm As Bookmark

For Each oBkm In ActiveDocument.Bookmarks
If InStr(oBkm.Range.Text, vbCr) Then
oBkm.Range.Font.Size = 10
 End If
 Next oBkm
End Sub
Charlie - 07 Jan 2005 21:18 GMT
PS. I copied the code out of your scratchmacro and inserted it right at the
end of my AutoNew() macro.

> I'd like to add some code that would check to see if the text of a bookmark
> field is two lines (containing a paragraph mark) and if it is, then to reduce
> the font of all those bookmarks to 10 point so it will fit in the allotted
> space in my form.  Thanks, charlie
Greg Maxey - 07 Jan 2005 22:05 GMT
Charlie,

Then you don't have bookmarked text in your document, you have REF Fields.
If you proviided the input via a ASK input screen then what you call
paragraph marks are line breaks.  Try:

Sub ScratchMacro()
Dim oFld As Field

For Each oFld In ActiveDocument.Fields
 If InStr(oFld.Result.Text, Chr(11)) > 0 Then
   oFld.Result.Font.Size = 10
 End If
Next oFld
End Sub

Signature

Greg Maxey/Word MVP
A Peer in Peer to Peer Support

> PS. I copied the code out of your scratchmacro and inserted it right
> at the end of my AutoNew() macro.
[quoted text clipped - 3 lines]
>> is, then to reduce the font of all those bookmarks to 10 point so it
>> will fit in the allotted space in my form.  Thanks, charlie
Charlie - 08 Jan 2005 16:50 GMT
GREAT!!!  This worked.  However, I need to update only a specific field with
the name {LOCATION}, but this changed other fields, too.  How do I change
this code to do only the field {location}?  many thanks, charlie

> Charlie,
>
[quoted text clipped - 19 lines]
> >> is, then to reduce the font of all those bookmarks to 10 point so it
> >> will fit in the allotted space in my form.  Thanks, charlie
Greg Maxey - 08 Jan 2005 19:01 GMT
Charlie,

What have your tried?

Try:

Sub ScratchMacro()
Dim oFld As Field

For Each oFld In ActiveDocument.Fields
  If oFld.Type = wdFieldRef Then
    If InStr(oFld.Code.Text, "Location") Then
     If InStr(oFld.Result.Text, Chr(11)) > 0 Then
        oFld.Result.Font.Size = 10
     End If
    End If
  End If
Next oFld
End Sub

Signature

Greg Maxey/Word MVP
A Peer in Peer to Peer Support

> GREAT!!!  This worked.  However, I need to update only a specific
> field with the name {LOCATION}, but this changed other fields, too.
[quoted text clipped - 28 lines]
>>>> is, then to reduce the font of all those bookmarks to 10 point so
>>>> it will fit in the allotted space in my form.  Thanks, charlie
Charlie - 12 Jan 2005 17:19 GMT
Many Many thanks, Greg
ps.  is there some kind of help file download that would help me with basic
word programming that would have lots of examples?  The built in help file
seems limited...  Thanks, Chalrie

> Charlie,
>
[quoted text clipped - 48 lines]
> >>>> is, then to reduce the font of all those bookmarks to 10 point so
> >>>> it will fit in the allotted space in my form.  Thanks, charlie
Greg - 12 Jan 2005 19:06 GMT
Charlie,

I am not aware of anything like that. Glad I was able to help.
Greg Maxey - 09 Jan 2005 02:16 GMT
or

Sub ScratchMacro()
Dim oFld As Field

For Each oFld In ActiveDocument.Fields
 If InStr(oFld.Code.Text, "Location") _
    And InStr(oFld.Result.Text, Chr(11)) > 0 Then
      oFld.Result.Font.Size = 10
 End If
Next oFld
End Sub

Signature

Greg Maxey/Word MVP
A Peer in Peer to Peer Support

> GREAT!!!  This worked.  However, I need to update only a specific
> field with the name {LOCATION}, but this changed other fields, too.
[quoted text clipped - 28 lines]
>>>> is, then to reduce the font of all those bookmarks to 10 point so
>>>> it will fit in the allotted space in my form.  Thanks, charlie
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.