Wafty
Fri Jun 02 06:12:55 CDT 2006
I've finally managed to get this working.
Thanks for all the help.
The code I've used is:
Borrowed macro from
http://www.necco.ca/dv/word_macros.htm
Sub ProcessFiles()
' Steven Marzuola
' Macro to run macros in all files inside a folder
'
myDirectory = "C:\Docs\"
ChangeFileOpenDirectory myDirectory
Dim CurrFile As String
CurrFile = Dir(myDirectory & "\*.doc")
Do While CurrFile <> ""
' Insert code to open a file. This will probably work:
Documents.Open FileName:=CurrFile
' Then call the macros
' [MISSING LINE]
Application.Run "DelInfo"
' Close the file if desired.
' [MISSING LINE]
ActiveWindow.Close SaveChanges:=SaveChanges
' Call the Dir command again to get the next filename.
CurrFile = Dir
Loop
End Sub
---------------------------------------------------------------------------------------------
Sub DelInfo()
'
' DelInfo Macro
' Macro recorded 5/30/2006 by Me
'
Selection.HomeKey Unit:=wdStory
Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.Font.Size = 24
Selection.Font.Bold = wdToggle
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
If Selection.Font.Underline = wdUnderlineNone Then
Selection.Font.Underline = wdUnderlineSingle
Else
Selection.Font.Underline = wdUnderlineNone
End If
Selection.TypeText Text:="My Random Title"
Selection.TypeParagraph
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or
ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
If Selection.HeaderFooter.IsHeader = True Then
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Else
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
End If
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Call WriteProp(sPropName:="Company", sValue:="")
Call WriteProp(sPropName:="Author", sValue:="")
Dim fMakeTitle As String
Dim strLastName As String, strFirstName As String
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.EndKey Unit:=wdLine
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.Copy
strLastName = Selection.Text
Selection.HomeKey Unit:=wdLine
Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Copy
strFirstName = Selection.Text
fMakeTitle = strLastName & ", " & strFirstName & ".doc"
ActiveDocument.SaveAs FileName:=fMakeTitle, FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="",
AddToRecentFiles:= _
True, WritePassword:="", ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:= _
False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
End Sub
Thanks again.
Wafty