Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Autoformat RTF

Posted on 2004-08-05
10
Medium Priority
?
329 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 240 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 260 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
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
Lost Word File? Eagerly, need it back? Read ahead; this File Recovery guide is for you.
In this video, we show how to convert an image-only PDF file into a PDF Searchable Image file, that is, a file with both the image (typically from scanning) and text, which is created in an automated fashion with Optical Character Recognition (OCR) …
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.

963 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