Apply formatting taken from one object to another?

R

Robin Tucker

Hiya,

I have a mergefield which I am dynamically replacing with a link in my code.
Even though the link says "\* MERGEFORMAT", it still does not retain
formatting when embedded in the document. So, I'm having to change its
formatting after it has been embedded.

So basically, how can I say something like myLink.Formatting =
myMergeField.Formatting - so that the embedded link has the same
font/formatting etc. as the mergefield I'm replacing with it.

Thanks



Robin
 
H

Helmut Weber

Hi Robin,
maybe this is sufficient:
Selection.CopyFormat
' do what you like
Selection.PasteFormat
 
R

Robin Tucker

Can this be done without Copy/Paste? I'm definately not using the clipboard
or application selection for any of my VBA stuff - really bad practice
unless the user is running macros (in this case, I'm automating report
generation, the user could be be working on a Word document while the report
is being generated, so I cannot assume the active document is the one I'm
hoping it is).
 
H

Helmut Weber

Hi Robin,
I don't think that copyformat uses
the clipboard a tall. At least,
it seems to have no effect
on the contents of the clipboard.
 
R

Robin Tucker

Well even so, it only applies to the Selection object, which I cannot use as
it is tied to the active document.
 
H

Helmut Weber

Hi,
just one more idea:
Dim oDoc As Document
Set oDoc = Documents("farben.doc")
Dim fnt As Font
Set fnt = oDoc.Paragraphs(3).Range.Font.Duplicate
oDoc.Paragraphs(1).Range.Font = fnt
Thanks to Martin Seelhofer
 
R

Robin Tucker

Yes, that would work for the font. I suppose I'll have to just go through
all formatting options in the source and set them in the destination like
this.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top