Sample script to run a macro...
Forums
Does anybody have an IDEAscript to run a macro?
Hi Drumond, here is some
Const AF_FIELD = 2
Const AF_RECORDNUMBER = 0
Const AF_USERDEFINETEXT = 1
Sub Main
End Sub
Function addActionField()
Dim db As database
Dim table As table
Dim field As field
Set db=Client.OpenDatabase("my database.imd)
Set table = db.TableDef
Set field = table.GetField("MY_FIELD" )
'1st parameter is script name
'Then takes up to 4 parameters to send to script, for more than that a work around is to create a text file and save the variables in the text file
'Each set of parameters first states if this is a field (2 - AF_FIELD) record number (0 - AF_RECORDNUMBER) or user defined text (1 - AF_USERDEFINETEXT )
'In this example the first 2 set of parameters is referencing FIELD1 and FIELD2 so the contents of these fields will be sent.
'The last two parameters are defined as user defined and being sent blank information.
field.SetActionFieldForIDEAScript "My Script.iss", AF_FIELD, "FIELD1", AF_FIELD, "FIELD2", AF_USERDEFINETEXT , "", AF_USERDEFINETEXT , ""
Set db = Nothing
Set table = Nothing
Set field = Nothing
End Function
Hi Brian - I am experimenting
Hi Brian - I am experimenting for the first time with scripting the action field that will run a macro. I have your script from above that is setting up the action field and it has worked correctly - I now have the action field. I am stuck on how do i get the parameters to pass? The scenario:
The action field is on a table that was created by suymmarizing on EMPLIDs. The EMPLID field is my action field. When the user clicks on an EMPLID on this table i want a different script to run that will basically open the original transaction file, extract all transactions matching that EMPLID then summarizing the activty and charting it. So i only have 1 paramter to pass - it is type AF_FIELD and the field name is "EMPLID" - the rest of the parameters are blank (""). So, in my testing to see if it is working I click on the EMPLID and the script runs to completion but it is not picking up the parameter EMPLID (so it is running the script against all transactions instead of just the ones for that EMPLID). When running a script from within a script the variables that have to be used are arg1, arg2, arg3, and arg4. Are there specific variable for this that have to be used as well? Thanks for any help.
Hi bakerroll,
Hi bakerroll,
I have attached an example for you. So in the database you would select define action field, select the IDEAScript to run, in my example it is the Action Field Demo.iss and then in the first parameter go in and select the field, such as the EMPLID. Now when it runs the script arg1 will have the contents of that parameter, and you can either transfer arg1 to another varialbe or use it in your script. The next message will contain the contents of the script, for some strange reason at work I can't mix code with other items, no idea why.
Brian
Sub Main
Sub Main
Set db = Client.OpenDatabase("Action Field Demo-Sheet1.IMD")
Set task = db.Extraction
task.IncludeAllFields
dbName = client.UniqueFilename("Emplid " & arg1 )
task.AddExtraction dbName, "", "EMPLID == """ & arg1 & """"
task.CreateVirtualDatabase = False
task.PerformTask 1, db.Count
Set task = Nothing
Set db = Nothing
Client.OpenDatabase (dbName)
client.RefreshFileexplorer
End Sub
Hi Drumond,
Hi Drumond,
Are you talking about running an IDEAScript from another IDEAScript? If so you can see this thread that has an example on how to do it: http://ideascripting.com/forum/call-script-within-script
Or do you mean something else with macro like an Excel macro?
Brian