View Single Post
  #5   Report Post  
Richie086 Richie086 is offline
Junior Member
 
Posts: 0
Default

[code]
Sub FileSave()
'
' FileSave Macro
' Saves the active document or template
'

UpdateAll ActiveDocument
ActiveDocument.Save

End Sub
Sub FileSaveAs()
'
' FileSaveAs Macro
' Saves a copy of the document in a separate file
'

Dialogs(wdDialogFileSaveAs).Show
UpdateAll ActiveDocument
ActiveDocument.Save

End Sub


Private Function UpdateAll(oDocument As Document) As Boolean
'Author: Graham Mayor, Microsoft MVP, 2003
'http://www.gmayor.dsl.pipex.com/installing_macro.htm
'Modified by Shauna Kelly, www.ShaunaKelly.com, 2003
Dim oStory As Range
Dim oTOC As TableOfContents

For Each oStory In oDocument.StoryRanges
oStory.Fields.Update
If oStory.StoryType wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Fields.Update
Wend
End If
Next oStory

For Each oTOC In ActiveDocument.TablesOfContents
'Oh mystery of life: why does *.Fields.Update not
'always update TOC fields? I don't know.
'But we need to do the TOCs explicitly.
oTOC.Update
Next oTOC

Set oStory = Nothing
Set oTOC = Nothing
End Function

[\code]

When I copy/paste the above code into the Macro editor in Word 2007, the following line of code shows up in red.

Code:
If oStory.StoryType wdMainTextStory Then
it seems as if wdMainTextStory is not being understood by the macro editor. I do not see any other mention of this variable anywhere in the code. When I try to run the macro I get a syntax error on that line of code.. Any ideas?