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. Doug



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
  #2   Report Post  
Cindy M -WordMVP-
 
Posts: n/a
Default

Hi Doug,

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).

I think I've seen this, once or twice, but not in a LONG time...

The one thing that comes to mind would be the "smart style" setting in Tools/Options/Edit/Settings.

You might also try turning options off/on in Tools/AutoCorrect Options/AutoFormat

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-)

  #3   Report Post  
Doug Martin via OfficeKB.com
 
Posts: n/a
Default

Thanks for that Cindy, unfortunately that didnt work so I have to wait for
our IT department to reset my Word options/settings to see if that helps.
Will post if it turns out ok.
D

--
Message posted via http://www.officekb.com
  #4   Report Post  
Doug Martin via OfficeKB.com
 
Posts: n/a
Default

Well the problem is sorted but how I'm not too sure. Started Word using
the 'Run' dialogue box to load Word without macros and templates (ie a new
Normal.dot), that on its own didnt fix it. So, recreated my template (just
the page layout) and copied over the macros and styles from my original,
and voila all works.
Found out some pretty interesting stuff about Master documents too, nasty,
but unfortunately needed.

--
Message posted via http://www.officekb.com
  #5   Report Post  
Cindy M -WordMVP-
 
Posts: n/a
Default

Hi Doug,

Well the problem is sorted but how I'm not too sure... recreated my

template (just
the page layout) and copied over the macros and styles from my original,
and voila all works.

In that case, I'm guessing some internal structures were damaged in the
template (stuff "stored in the last paragraph mark"). Thanks for reporting
back!

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)

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
Importing sub documents with AddFromFile is creating multiple styles Doug Martin via OfficeKB.com Formatting Long Documents 0 January 26th 05 09:54 PM
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
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 08:17 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"