Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.newusers
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
In Word 2007, how do I work within a form created in Word 2003? | New Users | |||
Mailmerge macro doesn't work in WORD 2007 | Mailmerge | |||
Word 2003 Macro Crashes Word 2007 | Microsoft Word Help | |||
Macro in word 2003 not working in word 2007 | New Users | |||
Print to Winfax macro doesn't work on Word or Excel 2003. | Microsoft Word Help |