Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
GvB GvB is offline
external usenet poster
 
Posts: 2
Default Insert document in section

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   Report Post  
Posted to microsoft.public.word.docmanagement
Stefan Blom Stefan Blom is offline
external usenet poster
 
Posts: 8,428
Default Insert document in section

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   Report Post  
Posted to microsoft.public.word.docmanagement
Stefan Blom Stefan Blom is offline
external usenet poster
 
Posts: 8,428
Default Insert document in section

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   Report Post  
Posted to microsoft.public.word.docmanagement
GvB GvB is offline
external usenet poster
 
Posts: 2
Default Insert document in section

Hi Stefan,

It's working fine as you suggested (per section). I'm not responsibble
for the filenames people give.

Thank you

Giel
  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Stefan Blom Stefan Blom is offline
external usenet poster
 
Posts: 8,428
Default Insert document in section

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to insert page numbers in only one section of a document Alexander[_3_] Page Layout 2 May 2nd 23 02:47 AM
Cannot insert more than one A3 section in document swimmer Microsoft Word Help 4 July 18th 07 08:58 AM
insert a section dsjr Page Layout 2 January 14th 07 03:18 AM
how to insert a references section at the very end of a document Uncle Scotty Microsoft Word Help 5 November 22nd 06 12:56 AM
Insert a section break and keep section together on one page Teri Page Layout 4 April 25th 06 06:20 PM


All times are GMT +1. The time now is 04:02 AM.

Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"