vba: possible to replace a varname with a document

M

Mark Findlay

Using vba, is it possible to replace a single word / string within a
document, with the entire contents of another document?

Many thanks!
Mark
 
J

Jezebel

yes. This is oversimplified, but should be enough to get you going:

Set Doc = Documents.Open(DocToInsert)
Doc.Content.Copy
Doc.Close

Selection.Find.Execute WordLookedFor
Selection.Paste
 
W

Word Heretic

G'day "Mark Findlay" <[email protected]>,

Yes. You write a Find routine, one of my skeletons for this is
available free from www.editorium.com back issues.

Use a find with no replace. This will set the host range (the
SomeRange in SomeRange.Find) to the span of the single word. You can
then use that range to InsertFile into. Repeat until no words found.

I haved used this method myself a number of times to dynabuild
documents. Its a good un.


Steve Hudson - Word Heretic
Want a hyperlinked index? S/W R&D? See WordHeretic.com

steve from wordheretic.com (Email replies require payment)


Mark Findlay reckoned:
 

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