Databases Reference
In-Depth Information
FIGURE 5.37 Template file utilized in Autoload and Extract example.
CreateDirectoryList RecSubDirs(i), SubDirs()
Next i
End If
CreateDirectoryList = subDirCount
End Function
The next step is to load in a template that contains the report format desired, which is shown
in Figure 5.37. The code to accomplish this is
'Load Template with Sample Report
ReportBook = Open_Template ("C:\Author\Books\Excel\Chapter
5\Samples\SampleReportFormat.xlt", "c:\temp\tempname.xls")
Function Open_Template (fulltemplatepath$, fullintpath$) As String
'Opens an Excel Template File and Then Saves it to a Temporary
Filename (fullintpath$)
'Returns the Name of the Template Workbook for storage to
Public Variable
'Open Template for Data Storage
If FileExists(fulltemplatepath$) <> True Then
MsgBox "You must install the file: " & fulltemplatepath$,
vbCritical + vbOKOnly, "File: " & fulltemplatepath$ & " Not Found"
End
End If
If DirectoryExists(Extract_Path(fullintpath$)) = False Then
Call CreateDataDir(Extract_Path(fullintpath$))
End If
'Open the Template
Workbooks.Open Filename:=fulltemplatepath$
'Save the Template as a new Workbook with an Intermediate name
'(This prevents corruption of the Original Template)
ActiveWorkbook.SaveAs Filename:=fullintpath$,
FileFormat:=xlNormal _
Search WWH ::




Custom Search