• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 332
  • Last Modified:

Autoformat RTF

Hi,
I have a template which recieves data and populates some bookmarks.
The data comes from a database application and one of the fields is RTF (with font info bundled).
The upshot being is that I end up with a doc that is times new roman 12pt for everything except a couple of lines with are 10pt Tahoma.
Any ideas on how to make this bookmark data conform to the TNR 12pt that the rest of the text is?
Format the bookmark (possible?)
Macro?
something else?

Cheers
Jay
0
QPR
Asked:
QPR
  • 4
  • 4
  • 2
2 Solutions
 
Joanne M. OrzechManager, Document Services CenterCommented:
Easiest way is Control A, and change the font to Times New Roman 12.
0
 
GrahamSkanRetiredCommented:
Perhaps you could explain how you are populating your bookmarks. Are you using a macro?

On many fFelds you can use the Mergeformat switch which does what you are asking for.

If you are using a macro, some minor modifications could do it.



0
 
QPRAuthor Commented:
3rd party application.
Access/SQL server.
Ability to assign variables to references/bookmarks within the word template.
When a certain event fires these variables are passed (auto) to the template and the bookmarks populated. Bit like a single document mail merge.
The end user simply prints the document and stuffs it in an envelope.... apart from the bit where they have to highlight the bookmark containing the RTF data and change the font. No biggie but would be nice to have them not have to do this step.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
Joanne M. OrzechManager, Document Services CenterCommented:
Not sure if this will help, but try Insert, Field, Mergefield, and make sure "preserve formatting during updates" is checked.
0
 
GrahamSkanRetiredCommented:
You could run this macro

Sub ChangeFont()
    With ActiveDocument.Content.Find
        .Font.Size = 10
        .Font.Name = "Tahoma"
        .Replacement.Font.Size = 12
        .Replacement.Font.Name = "Times New Roman"
        .Format = True
        .Execute Replace:=wdReplaceAll
    End With
End Sub

0
 
QPRAuthor Commented:
Hi Graham.
I changed your code to reflect what I'm trying to do but nothing is changing.
Have I used the wrong event? I don't fully understand the relationship between the template and the document other than the doc is a copy from a blueprint so to speak!

I opened the template and went to tools-macro-vb editor added this and saved.

Public Sub Document_Open()
    With ActiveDocument.Content.Find
        .Font.Size = 8.5
        .Font.Name = "Tahoma"
        .Replacement.Font.Size = 12
        .Replacement.Font.Name = "Times New Roman"
        .Format = True
        .Execute Replace:=wdReplaceAll
    End With
End Sub


The RTF field in the resulting .doc is still tahoma 8.5
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Did you try what I suggested in my first post?  If it works - that's the same macro Graham wrote.... Just curious.
0
 
QPRAuthor Commented:
HI JOrzech.
You mean the Control + A post?
I'm trying to achieve this with zero end user interaction if possible.

I looked at your other post...
Insert, Field, Mergefield, and make sure "preserve formatting during updates"
But not knowing huge amounts about bookmarks/merges I couldn't quite see what you meant. However, I did look where you suggested and the preserve formatting box is checked.

The template/document is launched by a 3rd party application. The on open sub can be found in both the template and the resulting document. However 2 things are noticed:
1. It doesn't work! (the rtf field is still tahoma)
2. No macro warnings when document opens (I'm *guessing* that this is because Word is being launched by the app as opposed to a user and so messages are suppresed (correct/rubbish?)
0
 
QPRAuthor Commented:
Hmmmm I've found a way to handle this from within the 3rd party app. Wrap a replace function around the call for the RTF text.
What should I do now? Have the Q deleted or split between all who answered?
Whats the norm protocol???
Come to think of it I'll split it while I'm here keep everything tidy

Cheers
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Thanks QPR!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now