MS Word 2010 VBA - Insert page

Gigabyte / P35c-ds3r
August 6, 2012 at 04:05:08
Specs: Windows 7 ultimate 64 bit, 3 GHz / 4094 MB
Hi all,

i need some help with a macro i am wring in MS Word 2010.

my master document has one page only (page1). On this page i have various information and also a combobox in the middle of this page within a table.

The combobox is used to insert other word documents into my master document. So basically if i select "Concrete" from the dropdown it will insert "W:\concrete.docx" into my master, same if i was to select "Steel" it will insert "W:\steel.docx" into my master.

The above works but here is the problem i need help with please:

I need the inserted file to be inserted at the end of my document, however it seems to go on my first page, at the top of page 1 and it moves my header to the last page, very wierd.

Secondly, as there are multiple options within the drop down, if someone picks one, and the file is inserted, then changes thier option in the dropdown, i want it to delete all page from 2 to the end, and insert the new file, i can do the insert part from cannot figure out how to delete pages from 2 to the end.

Here is the code i have so far:

Private Sub ComboBox1_Change()
    Dim TheRange
    FilePath = "W:\FileLocation\"

    Set TheRange = ActiveDocument.Content
    TheRange.Start = TheRange.End
    TheRange.InsertFile FileName:=FilePath & ComboBox1.Text & ".docx"

End Sub

any assistance would be greatfully recieved. thanks.

See More: MS Word 2010 VBA - Insert page

August 10, 2012 at 03:41:11
I am just testing something with this reply.

Report •

August 10, 2012 at 09:15:33
I thought I sent this to the Office forum. What's it doing in Programming?

How To Ask Questions The Smart Way

Report •

August 10, 2012 at 09:39:06
Hi Razor,

Sorry about that, could you possibly move this o the office forum please?


Report •
Related Solutions

Ask Question