Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Hi,
I'm trying to create a macro that is going to insert a document per section. I have allready created a standard macro in Office 2000 like: Selection.InsertFile FileName:="test.doc", Range:= _ "", ConfirmConversions:=False, Link:=False, Attachment:=False This inserts the document in the selected section. In my case I have created a document with 10 sections. Each section is using a differend document that I want to insert. Any advice would be appreciated. Regards, Giel |
#2
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
You will have to access each section, replacing its contents with the
inserted document. You can iterate the sections (in a For loop, for example), if you can easily access Assuming that the document names are "test1", "test2" etc. this wouldn't be so difficult. Sub tryout() Dim s As Section Dim r As Range For Each s In ActiveDocument.Sections Set r = s.Range r.End = r.End - 1 r.InsertFile Link:=False, _ FileName:="c:\\documents and settings\\sbm01004\\desktop\\tryout.doc" Next s End Sub -- Stefan Blom Microsoft Word MVP "GvB" wrote in message ... Hi, I'm trying to create a macro that is going to insert a document per section. I have allready created a standard macro in Office 2000 like: Selection.InsertFile FileName:="test.doc", Range:= _ "", ConfirmConversions:=False, Link:=False, Attachment:=False This inserts the document in the selected section. In my case I have created a document with 10 sections. Each section is using a differend document that I want to insert. Any advice would be appreciated. Regards, Giel |
#3
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Sorry about the somewhat confusing message (posted by mistake)...
My point is that if you want to iterate sections, you will have to name the files test1.doc, test2.doc or something like that, so that you can easily insert them via a For...Next loop. If you don't have names like that, you will have to deal with each section separately. For example: Sub Test() Dim r As Range 'First section, first doc to insert: Set r = ActiveDocument.Sections(1).Range.Duplicate r.End = r.End - 1 r.InsertFile Link:=False, _ FileName:="c:\\documents and settings\\sbm01004\\desktop\\tryout.doc" 'Second section, second doc to insert: Set r = ActiveDocument.Sections(2).Range.Duplicate r.End = r.End - 1 r.InsertFile Link:=False, _ FileName:="c:\\documents and settings\\sbm01004\\desktop\\test.doc" '[and so on] End Sub The simple loop in my previous message inserts the same document in all sections. -- Stefan Blom Microsoft Word MVP "Stefan Blom" wrote in message ... You will have to access each section, replacing its contents with the inserted document. You can iterate the sections (in a For loop, for example), if you can easily access Assuming that the document names are "test1", "test2" etc. this wouldn't be so difficult. Sub tryout() Dim s As Section Dim r As Range For Each s In ActiveDocument.Sections Set r = s.Range r.End = r.End - 1 r.InsertFile Link:=False, _ FileName:="c:\\documents and settings\\sbm01004\\desktop\\tryout.doc" Next s End Sub -- Stefan Blom Microsoft Word MVP "GvB" wrote in message ... Hi, I'm trying to create a macro that is going to insert a document per section. I have allready created a standard macro in Office 2000 like: Selection.InsertFile FileName:="test.doc", Range:= _ "", ConfirmConversions:=False, Link:=False, Attachment:=False This inserts the document in the selected section. In my case I have created a document with 10 sections. Each section is using a differend document that I want to insert. Any advice would be appreciated. Regards, Giel |
#4
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
Hi Stefan,
It's working fine as you suggested (per section). I'm not responsibble for the filenames people give. Thank you Giel |
#5
![]()
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
![]()
You are welcome--and thank you for the feedback.
-- Stefan Blom Microsoft Word MVP "GvB" wrote in message ... Hi Stefan, It's working fine as you suggested (per section). I'm not responsibble for the filenames people give. Thank you Giel |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how to insert page numbers in only one section of a document | Page Layout | |||
Cannot insert more than one A3 section in document | Microsoft Word Help | |||
insert a section | Page Layout | |||
how to insert a references section at the very end of a document | Microsoft Word Help | |||
Insert a section break and keep section together on one page | Page Layout |