christenhusz
Technical User
Hi,
I wrote a script which change the catalog path and name in a imr report. This works fine but only for the 1 hardcoded directory. Now I have a directory structure with 4 levels of subdirectories and they all contain imr reports. This means I have to change the report directory for every subdirectory and then compile and run the macro… I’m thinking about writing a recursive function which will browse through the directory structure.
My question: does anyone wrote a similar function? And if so, can I get this function.? I'll reward your effort with a star !
Here is the code:
'******************************************************************************
'* Date: 21-08-2004 *
'* Version: 1.0 *
'* Author: Martijn Christenhusz *
'* Description: *
'* *
'* With this macro you can change the catalog location of reports. *
'* 1 Open the catalog *
'* 2 Open the first report *
'* 3 Save the report *
'* 4 Close the report *
'* 5 Repeat step 2 to 4 until all the files are done *
'******************************************************************************
Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Sub Main()
Dim objImpApp As Object
Dim objImpRepp As Object
Dim NewCatalogPath As String
Dim ReportName As String
Dim FileName As String
Dim ReportDirectory As String
'Set new catalog path and report directory
NewCatalogPath = "C:\temp\RBI Outdoors new.CAT"
ReportDirectory = "C:\Temp\input\*.imr"
'open application and make application visable
Set objImpApp = CreateObject("Impromptu.Application")
objImpApp.Visible 1
'open catalog as catalog creator
objImpApp.OpenCatalog NewCatalogPath,"Creator","sa"
'Set directory to scan
FileName= Dir (ReportDirectory)
Do While FileName<>""
ReportName = mid(ReportDirectory,1,Len(ReportDirectory) -5) & FileName
Set objImpRepp = objImpApp.OpenReport (ReportName)
'Give Impromptu some time to open the report and retrieve the data.
Call Sleep(3000)
'Save the active report' the new catalog loaction will be saved.
objImpRepp.Save
'Close the active report
objImpRepp.CloseReport
FileName=Dir
Loop
'Close IMP
objImpApp.Quit
'Clear Memory
Set objImpRepp = Nothing
Set objImpApp = Nothing
End Sub
Thanks!
I wrote a script which change the catalog path and name in a imr report. This works fine but only for the 1 hardcoded directory. Now I have a directory structure with 4 levels of subdirectories and they all contain imr reports. This means I have to change the report directory for every subdirectory and then compile and run the macro… I’m thinking about writing a recursive function which will browse through the directory structure.
My question: does anyone wrote a similar function? And if so, can I get this function.? I'll reward your effort with a star !
Here is the code:
'******************************************************************************
'* Date: 21-08-2004 *
'* Version: 1.0 *
'* Author: Martijn Christenhusz *
'* Description: *
'* *
'* With this macro you can change the catalog location of reports. *
'* 1 Open the catalog *
'* 2 Open the first report *
'* 3 Save the report *
'* 4 Close the report *
'* 5 Repeat step 2 to 4 until all the files are done *
'******************************************************************************
Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Sub Main()
Dim objImpApp As Object
Dim objImpRepp As Object
Dim NewCatalogPath As String
Dim ReportName As String
Dim FileName As String
Dim ReportDirectory As String
'Set new catalog path and report directory
NewCatalogPath = "C:\temp\RBI Outdoors new.CAT"
ReportDirectory = "C:\Temp\input\*.imr"
'open application and make application visable
Set objImpApp = CreateObject("Impromptu.Application")
objImpApp.Visible 1
'open catalog as catalog creator
objImpApp.OpenCatalog NewCatalogPath,"Creator","sa"
'Set directory to scan
FileName= Dir (ReportDirectory)
Do While FileName<>""
ReportName = mid(ReportDirectory,1,Len(ReportDirectory) -5) & FileName
Set objImpRepp = objImpApp.OpenReport (ReportName)
'Give Impromptu some time to open the report and retrieve the data.
Call Sleep(3000)
'Save the active report' the new catalog loaction will be saved.
objImpRepp.Save
'Close the active report
objImpRepp.CloseReport
FileName=Dir
Loop
'Close IMP
objImpApp.Quit
'Clear Memory
Set objImpRepp = Nothing
Set objImpApp = Nothing
End Sub
Thanks!