Reply
 
Thread Tools Display Modes
  #1   Report Post  
Doug Martin via OfficeKB.com
 
Posts: n/a
Default Importing sub documents with AddFromFile is creating multiple styles

I use the macro below to import about 13 documents (full list not listed here to save space) into a Main document using Word 2000. All of the documents have been saved off of the Main document (using the main doc as a template) and they all run off the same .dot template for the styles.

Now, my problem is that it has been working fine up until I tweaked something or changed a setting somewhere (which I cannot think what) and now when I run the macro it brings all the documents in perfectly but multiplies most of the styles with the same name from the 13 documents ie:
New bullet
New bullet1
New bullet2
New bullet3 etc etc up to 13.
This problem also exists if I try and manually copy all the information from the sub documents into the main document (although it doesn?t seem as bad).

My question is, is there a line of code I can add or a setting which will rectify this problem? I have trawled through many forums regarding this but have yet to find a solution.

Any help will be much appreciated,



Sub ImportSubDocuments()
On Error GoTo ImportSubDocuments_Err

Dim sFile As String
' ActiveDocument.Paragraphs.TabStops.ClearAll
ActiveWindow.ActivePane.View.Type = wdMasterView
Selection.Paragraphs.OutlinePromote

'stop the message box informing about styles being different
Application.DisplayAlerts = wdAlertsNone

sFile = "Introduction.doc"
ChangeFileOpenDirectory _
sMainDirectory & "Introduction\"
ActiveDocument.Subdocuments.AddFromFile Name:=sFile, _
ConfirmConversions:=False, ReadOnly:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:=""


sFile = "Consumer.doc"
ChangeFileOpenDirectory _
sMainDirectory & "Consumer\"
Selection.Range.Subdocuments.AddFromFile Name:=sFile, _
ConfirmConversions:=False, ReadOnly:=False, PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:=""

Exit Sub

ImportSubDocuments_Err:
If Err.Number = 5174 Then
MsgBox "Subdocument " & sFile & " can not be found, please check document name and location", vbExclamation, "Subdocument not found"
Else
MsgBox Err.Description & vbNewLine & Err.Number, vbExclamation, "Error loading subdocuments"
End If
End Sub

--
Message posted via http://www.officekb.com
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
removing styles across multiple documents jd_editor Microsoft Word Help 1 January 20th 05 09:41 PM
Creating one document out of multiple documents kamy107 Microsoft Word Help 1 January 14th 05 03:06 PM
Using Back Arrow when hyperlinking - multiple documents O. Hardin Microsoft Word Help 0 January 13th 05 09:09 PM
Multiple styles in a single paragraph skibikegolf Microsoft Word Help 1 January 5th 05 09:57 AM
Importing Styles Charles Kenyon New Users 0 November 24th 04 11:38 PM


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

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

About Us

"It's about Microsoft Word"