A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » New Users
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Word 2003 Macro not work in Word 2007



 
 
Thread Tools Display Modes
  #1  
Old February 26th, 2009, 06:52 PM posted to microsoft.public.word.newusers
aliao
external usenet poster
 
Posts: 2
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




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 10:28 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.