8
82whiskey
Hi all,
I just learned today that our old vba scripts written in Office 2003
will not work in Office 2007 specifically the Application.FileSearch
command. I've been doing some reading here but I don't understand vba
well enough to figure this out so some help would be appreciated.
Below is a script designed to search a single directory for .doc files
and combine them into one doc file. I'm hoping there is a simple fix
to get the script to run.
Thanks in advance
Brian
Sub CompileDailyFax()
Dim i As Integer
'Macro created 05/25/00 by Brian Avila
Documents.Add
With Application.FileSearch
.LookIn = "N:\Daily Fax\"
'Put the name of the folder you want to search after the lookin
property
.FileName = "*.doc"
'.FileName = type of files you want to search for
.Execute
If .FoundFiles.Count > 0 Then
For i = 1 To .FoundFiles.Count
Selection.Collapse direction:=wdCollapseEnd
Selection.InsertFile .FoundFiles(i)
If i <> .FoundFiles.Count Then
Selection.InsertBreak Type:=wdSectionBreakNextPage
ActiveDocument.Fields.Update
End If
Next i
End If
End With
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(0.02)
.BottomMargin = InchesToPoints(0.55)
.LeftMargin = InchesToPoints(0.7)
.RightMargin = InchesToPoints(0.7)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.2)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
End With
End Sub
I just learned today that our old vba scripts written in Office 2003
will not work in Office 2007 specifically the Application.FileSearch
command. I've been doing some reading here but I don't understand vba
well enough to figure this out so some help would be appreciated.
Below is a script designed to search a single directory for .doc files
and combine them into one doc file. I'm hoping there is a simple fix
to get the script to run.
Thanks in advance
Brian
Sub CompileDailyFax()
Dim i As Integer
'Macro created 05/25/00 by Brian Avila
Documents.Add
With Application.FileSearch
.LookIn = "N:\Daily Fax\"
'Put the name of the folder you want to search after the lookin
property
.FileName = "*.doc"
'.FileName = type of files you want to search for
.Execute
If .FoundFiles.Count > 0 Then
For i = 1 To .FoundFiles.Count
Selection.Collapse direction:=wdCollapseEnd
Selection.InsertFile .FoundFiles(i)
If i <> .FoundFiles.Count Then
Selection.InsertBreak Type:=wdSectionBreakNextPage
ActiveDocument.Fields.Update
End If
Next i
End If
End With
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(0.02)
.BottomMargin = InchesToPoints(0.55)
.LeftMargin = InchesToPoints(0.7)
.RightMargin = InchesToPoints(0.7)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.2)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.5)
.PageHeight = InchesToPoints(11)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
End With
End Sub