Variables as parameters
Forums
Hi! Can you help me!?
I'm learning how to do some scripts, but really (really) new to it.
I'm currently trying to create a script that uses the same file to do different things.
Now I'm oppening the file a lot of times to get it's different sheets.
Is that possible to create a function to open the file, and then get those different sheets? Probably passing the address of the file as a parameter.
</code>
Sub Main
Call OpenFile()
Call ExcelImport_sheet1()
Call ExcelImport_sheet2()
Function OpenFile
dbName1 = InputBox ("Insert file address")
End Function
Function ExcelImport_sheet1
dbName1 = OpenFile(dbName1) 'I need something like that
Set task = Client.GetImportTask("ImportExcel")
task.FileToImport = dbName1
task.SheetToImport = "test"
task.OutputFilePrefix = "A2_test"
task.FirstRowIsFieldName = "TRUE"
task.EmptyNumericFieldAsZero = "FALSE"
task.PerformTask
dbName = task.OutputFilePath("At_test")
Set task = Nothing
Client.OpenDatabase(dbName)
End Function
end Sub
<code\>
I saw an example here (https://www.ideascripting.com/forum/passing-variables-functions-and-subs) but I didn't really understand it.Would you mind helping me out, please?
Sorry, already solved it with
Sorry, already solved it with:
Function OpenFile
dbName1 = InputBox ("file address")
ExcelImport(dbName1)
(: