Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.newusers
aliao aliao is offline
external usenet poster
 
Posts: 1
Default Word 2003 Macro not work in Word 2007

Hi,

I have a Word macro to combine a list of rtf files into one new rtf file and
also create TOC that works in Word 2003 but not work after upgrading to Word
2007 for the following:

With ActiveDocument.Styles("TOC 1")
WordBasic.FileSaveAs Name:=path$ + outfile$ + ".rtf", Format:=0

Need some help on how to modify the macro since I am not too familiar with
VB codes. Do I have to create a new Style called TOC 1?

Thanks in advance!

Below is my macro called "Combined":


Sub combined()
Dim curdoc$
Dim path$
Dim outfile$
Dim fnt$
Dim fns$
Dim findoc$
findoc$ = Space(20)
curdoc$ = Space(255)
path$ = Space(255)
outfile$ = Space(255)
fnt$ = Space(255)
fns$ = Space(255)
Dim orient$
Dim FNs_
Open "C:\Temp\tlist.txt" For Input As 1
While Not EOF(1)
Input #1, curdoc$, path$, outfile$, fnt$, fns$, orient$
FNs_ = WordBasic.Val(fns$)
orient$ = WordBasic.[Ucase$](orient$)
findoc$ = WordBasic.Mid(curdoc$, 1, (InStr(curdoc$, ".") - 1))
WordBasic.FileOpen Name:=path$ + curdoc$
WordBasic.StartOfDocument
WordBasic.EditSelectAll
WordBasic.FilePageSetup RightMargin:="0.7 in", TopMargin:="1.0 in"
WordBasic.FilePageSetup BottomMargin:="0.5 in", LeftMargin:="0.7 in"
If WordBasic.[RTrim$](orient$) = "LANDSCAPE" Then
WordBasic.FilePageSetup Orientation:=1
WordBasic.FilePageSetup PageHeight:="8.5 in", PageWidth:="11 in"
Else
WordBasic.FilePageSetup Orientation:=0
WordBasic.FilePageSetup PageWidth:="11 in", PageHeight:="8.5 in"
End If
If FNs_ = 6 Then WordBasic.FontSize 6
If FNs_ = 7 Then WordBasic.FontSize 7
If FNs_ = 8 Then WordBasic.FontSize 8
If FNs_ = 9 Then WordBasic.FontSize 9
If FNs_ = 10 Then WordBasic.FontSize 10
WordBasic.Font fnt$
'WordBasic.FileSaveAs Name:=path$ + findoc$ + ".rtf", Format:=0
WordBasic.FileClose 1
Wend
Close 1
WordBasic.FileNewDefault
Open "c:\temp\tlist.txt" For Input As 1
While Not EOF(1)
Input #1, curdoc$, path$, outfile$, fnt$, fns$, orient$
WordBasic.InsertFile Name:=path$ + curdoc$, Link:=1
WordBasic.InsertSectionBreak
Wend
Close 1

Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1"
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With

Selection.Fields.Update

Selection.WholeStory

With Selection.Font

.Name = "Courier New"
.Size = 7
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorAutomatic
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0
.Scaling = 100
.Position = 0
.Kerning = 0
.Animation = wdAnimationNone

End With

With ActiveDocument.Styles("TOC 1")
.AutomaticallyUpdate = True
.BaseStyle = "Normal"
.NextParagraphStyle = "Normal"
End With
With ActiveDocument.Styles("TOC 1").ParagraphFormat
.LeftIndent = InchesToPoints(0)
.RightIndent = InchesToPoints(0)
.SpaceBefore = 12
.SpaceBeforeAuto = False
.SpaceAfter = 12
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = InchesToPoints(0)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
End With
ActiveDocument.Styles("TOC 1").NoSpaceBetweenParagraphsOfSameStyle = False

WordBasic.FileSaveAs Name:=path$ + outfile$ + ".rtf", Format:=0
'WordBasic.FileCloseAll 1
End Sub




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
In Word 2007, how do I work within a form created in Word 2003? Julie New Users 1 February 19th 09 08:03 PM
Mailmerge macro doesn't work in WORD 2007 [email protected] Mailmerge 9 June 3rd 08 12:47 PM
Word 2003 Macro Crashes Word 2007 brownkckc Microsoft Word Help 1 May 21st 08 04:02 PM
Macro in word 2003 not working in word 2007 vestlink New Users 1 March 14th 08 11:11 AM
Print to Winfax macro doesn't work on Word or Excel 2003. Shiraleo Microsoft Word Help 2 November 6th 05 07:18 AM


All times are GMT +1. The time now is 09:31 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"