-
Insert a formatted table from Doc.1 to Doc.2
So recently I tried a really simple code which sort of worked but not the way I wanted it to. More over I don't really want to 'replace' one bookmark for another.
[VBA]
Documents("c:\temp\document2.doc").Bookmarks("doc2BookmarkName").Range.Text = _
Documents("c:\temp\document1.doc").Bookmarks("doc1BookmarkName").Range.Text
[/VBA]
So what I want to do is take a specific table in a master table doc I've created (doc.1) then want it to paste the selected table, all of the headings/ text contained in the table and format, into doc.2 when that specific macro is run.
There will be numeruos macros like this say 15 all of which pull different tables and paste them into doc.2. Think of it as a simple cut and paste from one document to another. This is just to help speed up the process instead of having to sift through the master doc or having to find other documents where the tables exist. I did try the record macro but was dismayed when I realized once my clipboard was emptied the macro didn't work.
As you can tell I'm new at this and would appreciate any and all help in regards to this matter.
-
Here's an example.
[VBA]Sub CopyFormatted()
Dim aDoc As Document
Dim bDoc As Document
Dim aTbl As Table
Dim Rng As Range
Set aDoc = ActiveDocument
Set aTbl = aDoc.Tables(1)
aTbl.Range.Copy
Set bDoc = Documents.Add
bDoc.Range.FormattedText.Paste
End Sub[/VBA]
So, what you're looking for is FormattedText, however you decide to code it.
-
David,
Thank you so very much for your response. I will give it a shot today some time. In any case your help is truly appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules