Solved

Autoformat RTF

Posted on 2004-08-05
10
316 Views
Last Modified: 2008-03-06
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
Comment
Question by:QPR
  • 4
  • 4
  • 2
10 Comments
 
LVL 37

Assisted Solution

by:Joanne M. Orzech
Joanne M. Orzech earned 60 total points
ID: 11738461
Easiest way is Control A, and change the font to Times New Roman 12.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 65 total points
ID: 11738500
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
 
LVL 29

Author Comment

by:QPR
ID: 11740084
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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 11742487
Not sure if this will help, but try Insert, Field, Mergefield, and make sure "preserve formatting during updates" is checked.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 11745611
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
 
LVL 29

Author Comment

by:QPR
ID: 11748247
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
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 11749590
Did you try what I suggested in my first post?  If it works - that's the same macro Graham wrote.... Just curious.
0
 
LVL 29

Author Comment

by:QPR
ID: 11749630
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
 
LVL 29

Author Comment

by:QPR
ID: 11749916
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
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 11752691
Thanks QPR!
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is a feature provided by MS Word that lets you create an Table of Contents for your Word document automatically. To use this feature for other documents there are two steps involved,   1.  Prepare your document for a table of contents (he…
If you work with Word a lot, you probably use styles. If you use styles a lot, you've probably balled your fist more often than not when working with the ribbon. In Word 2007/2010, one of the things that I find missing when using styles is a quic…
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question