+ Reply to Thread
Results 1 to 3 of 3

Insert Word Document with a macro, retain original formatting

  1. #1
    Registered User
    Join Date
    11-26-2013
    Location
    Tucxon, AZ
    MS-Off Ver
    Office 10 and 13
    Posts
    2

    Insert Word Document with a macro, retain original formatting

    Hi all,

    I am trying to create a macro that will insert a separate Word document into the one I'm working on, but retain the original formatting of the separate document.

    Confused yet? Let me explain. I have a master form that folks are filling out. If they need to add an additional page of contacts, I have them clicking a checkbox, which runs a macro to insert the new page. The contact page is a separate document. The contact page is set up with a font size of 11. However, when my macro inserts the contact page, it changes the font size to 12, which totally screws up the layout.

    Here's the code I currently have:

    Selection.EndKey Unit:=wdStory
    Selection.InsertBreak Type:=wdPageBreak
    ChangeFileOpenDirectory "N:\Attachments\"
    Selection.InsertFile FileName:= _
    "N:\Attachments\Mailing List Intake Form.docm" _
    , Range:="", ConfirmConversions:=False, Link:=False, Attachment:=False

    What should I add to this code to make it keep the font size of 11? Any ideas would be greatly appreciated!

    Thanks!

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Insert Word Document with a macro, retain original formatting

    You can only do that using the InsertFile method when the source document honours the Style definitions found in the destination document. If the Style definitions are not the same, or are not honoured in the source document, the results cannot be guaranteed when using the InsertFile method. Your choices, therefore, are to (a) ensure the Style definitions are the same and are honoured in the source document; or (b), open, copy & paste the source document, using 'PasteAndFormat (wdFormatOriginalFormatting)'.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Registered User
    Join Date
    11-26-2013
    Location
    Tucxon, AZ
    MS-Off Ver
    Office 10 and 13
    Posts
    2

    Re: Insert Word Document with a macro, retain original formatting

    Thanks for the reply! I was afraid that was going to be the case, so I changed the layout of my inserted document to be a little more forgiving of font size. Not the ideal solution, but it's working.

    Thanks again!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Import data from Word document and keep original formatting
    By dougdrex in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 06-11-2013, 03:52 PM
  2. Retain formatting of original list (Data Validation)
    By demonfly100 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-28-2012, 07:19 AM
  3. How to retain only text in a word document?
    By daksh1981 in forum Word Programming / VBA / Macros
    Replies: 2
    Last Post: 07-20-2010, 02:16 AM
  4. Retain text format from a WORD document
    By Willisbar in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 02-09-2005, 11:06 PM
  5. Replies: 0
    Last Post: 02-02-2005, 04:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1