Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / August 2006

Tip: Looking for answers? Try searching our database.

Create EXACT Duplicate of Current Doc - Inclyding pictures and tab

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MDW - 16 Aug 2006 21:13 GMT
I've got a Word 2003 document that contains a lot of embedded pictures and
tables. I'm trying to write a macro that will make new document that is an
exact duplicate of the first couple of pages, down to the formatting and
containing all the pictures and whatnot.

Below is the code that grabs the first couple of pages. However, it doesn't
seem to work right:

Set objDoc = ThisDocument
Set objNew = Application.Documents.Add

objNew.PageSetup = objDoc.PageSetup

Set objRG = objDoc.Range(0, lngEnd)
objNew.Content.InsertBefore objRG

Set objNew = Nothing
Set objDoc = Nothing

"lngEnd" is a variable that represents the character at the very end of the
last page I want to copy.

What happens is that the text part is transferred over, but it doesn't bring
over the pictures, the tables, etc. Also, any text effects (font size, bold,
etc) aren't translated. Plus it adds a lot of extra pages.

Obviously this is not the right technique to do this kind of thing....what
do I need to change??

TIA.
Signature

Hmm...they have the Internet on COMPUTERS now!

Dave Lett - 16 Aug 2006 21:21 GMT
Try this instead:

In the original document, insert a bookmark at the location where you want
to have the exact replica document END.

Then include the following in your routine:

Dim oRng as Range
ActiveDocument.SaveAs FileName:="Replica"
Set oRng = ActiveDocument.Range _
   (Start:=ActiveDocument.Bookmarks("ReplicaEnd").Range.Start, _
   End:=ActiveDocument.Range.End)
oRng.Delete

HTH,
Dave

> I've got a Word 2003 document that contains a lot of embedded pictures and
> tables. I'm trying to write a macro that will make new document that is an
[quoted text clipped - 30 lines]
>
> TIA.
Jezebel - 17 Aug 2006 00:14 GMT
Why not just save a copy of the old document and delete what you don't want?

> I've got a Word 2003 document that contains a lot of embedded pictures and
> tables. I'm trying to write a macro that will make new document that is an
[quoted text clipped - 30 lines]
>
> TIA.
MDW - 17 Aug 2006 17:08 GMT
Because I'm....an idiot? *LOL*

Thanks.

Signature

Hmm...they have the Internet on COMPUTERS now!

> Why not just save a copy of the old document and delete what you don't want?
>
[quoted text clipped - 32 lines]
> >
> > TIA.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.