Solved

How to save bookmark formatting in VBA

Posted on 2007-03-26
1
273 Views
Last Modified: 2012-08-13
I have a macro that saves the range of a bookmark, but I want to keep the formatting of the text in the bookmark also.  How can I do that?

Here is some code I use:

Set Rng1 = ActiveDocument.Bookmarks("SerialNumber").Range

    Rng1.Delete
    Rng1.Text = SerialNumber

SO, you can see that I am trying replace the SerialNumber in the range.  I have formatted the bookmark, but it appears that also gets deleted and the default formatting is used.

Thanks
Ep
0
Comment
Question by:dickep
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 14

Accepted Solution

by:
Glenn_Moore earned 500 total points
ID: 18799836
Create your own macro with the formatting you want, and then incorporate this text into your routine.

To record a macro to conditionally format:

Open up a document with your Bookmark, Tools, Macro, Record New Macro, give it a name, and conditionally format yourbookmark .  Stop recording.  
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …

733 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