Making use of a source file path variable

12 posts / 0 new
Last post
rahulsaxena3
Offline
Joined: 01/09/2018 - 14:02

Hi Brian,
I have a simillar doubt regarding declaring a variable in one macro script and then using the variable's value defined by the end user in the first macro in the second macro. To give you more perspective this is the code i am working on:
Macro 1: 
Option Explicit
Global sFilename As String
( The variable sFilename then will contain the name of the database selected by the user, it was taken from your field mapping script template )
Macro 2:
Sub Main
Call TopNExtraction()'sFilename is the variable database name
client.RefreshFileExplorer
Call ExportDatabaseXLSX()'KPI 1.IMD
End Sub
 
' Data: Top Records Extraction
Function TopNExtraction
Set db = Client.OpenDatabase(sFilename)
Set task = db.TopRecordsExtraction
Dim dbName As String ' Made an addition while using sFilename as a variable
task.IncludeAllFields
task.AddKey "CREDIT", "A"
dbName = "KPI 1.IMD"
task.OutputFileName = dbName
task.NumberOfRecordsToExtract = 30
task.CreateVirtualDatabase = False
task.PerformTask
Set task = Nothing
Set db = Nothing
Client.OpenDatabase (dbName)
End Function
--------------
My end goal is that the after the user selects the database and maps the neccesary fields in the dialogue box, the 2nd Macro which has the actual analysis to be run, then selects that database from the variable defined in the 1st Macro i.e. sFilename.
Please help me here, i am stuck.

Pages