Page 1 of 1

Calling a Macro From TI

Posted: Wed Feb 15, 2012 6:55 am
by sg2012
Hi All,
Is there any way to Call Macro from TI?

{Admin Note: Split from the topic "MACRO to Create a TI" since this thread has nothing to do with that topic.}

Re: Calling a Macro From TI

Posted: Wed Feb 15, 2012 7:54 am
by Alan Kirk
sg2012 wrote:Hi All,
Is there any way to Call Macro from TI?
No. TIs run on the server, macros run on the client side. If you look through the list of TI functions you'll notice that the one consistent thing is that they all do something on the server, never on the client. Off the top of my head I can't think of an exception to that. In many cases (scheduled chores) there won't even be a client.

Re: Calling a Macro From TI

Posted: Wed Feb 15, 2012 8:11 pm
by Martin Ryan
Only workaround would be to run a batch file that loads the Excel workbook that runs the macro on load. But I'm sure there would be better ways.

What are you trying to achieve? The only thing I can assume is that you want to run a TI process, then run a macro. If that's the case, then call the TI process from Excel, then run the second macro.

Martin

Re: Calling a Macro From TI

Posted: Thu Feb 16, 2012 5:29 am
by sg2012
Even I was thinking of running a bat file.
But I dont want Macro to run at load time since I want the macro to record the time when I click on Action Button(Action Button runs TI.)

So I am thinking of Calling bat file from my TI.
And that bat file will call macro.

But then how to call bat file from TI?
Is there any command for the same?

Re: Calling a Macro From TI

Posted: Thu Feb 16, 2012 5:42 am
by Gregor Koch
Yes, there is.
Not telling though because I think the suggestions you already received in two other threads will be a better and also much easier way of achieving what you are trying to do.

Re: Calling a Macro From TI

Posted: Thu Feb 16, 2012 5:43 am
by Alan Kirk
sg2012 wrote:Even I was thinking of running a bat file.
But I dont want Macro to run at load time since I want the macro to record the time when I click on Action Button(Action Button runs TI.)

So I am thinking of Calling bat file from my TI.
And that bat file will call macro.
Or alternatively you have the TI write the value into a cube and read the cube value from a DBRW. In fact I'm sure that the same question with the same answer (from someone else) came up not so long ago. It's many times lower in complexity and higher in reliability.
sg2012 wrote:But then how to call bat file from TI?
Is there any command for the same?
"Before posting, please check the..." Oh what's the point. It's here.

Re: Calling a Macro From TI

Posted: Fri Feb 17, 2012 6:10 am
by sg2012
Hey I am So Sorry.
I framed wrong Question.
Yeah I knew ExecuteCommand().
But how to call Macro from bat file?

I have found something like this:
C:\temp\test.txt /m="C:\temp\macro.mac"
But its not workin..
Any other alternative?

Re: Calling a Macro From TI

Posted: Fri Feb 17, 2012 8:30 am
by Alan Kirk
sg2012 wrote:Hey I am So Sorry.
I framed wrong Question.
Yeah I knew ExecuteCommand().
But how to call Macro from bat file?

I have found something like this:
C:\temp\test.txt /m="C:\temp\macro.mac"
But its not workin..
Gee, I wonder why. Perhaps had you quoted the entire command line of

Code: Select all

uedit32 c:\temp\test.txt /m="c:\temp\macro.mac"
which you presumably found on this link (and which you quoted without taking the time to read through the entire context of the page), you would have understood that that was unlikely to work unless you bought the Ultra Edit application from the company concerned. Those are not native batch commands, they're commands for Ultra Edit.

Since this is a really, really bad idea (as you've been told repeatedly by many people), and since I'm not in the business of propagating really, really bad ideas, I'm not going to spell out the solution.

But while I won't give you an actual road map to Hell, I will, however, give you a compass and point you in the right direction. It's then up to you whether you want to walk that path and if you do, well, Pilate isn't the only Roman who washes his hands of the consequences.

Consider:
- A Batch file can be used to launch the Excel executable (excel.exe) by simply specifying the full path to it.
- When you use a command line to launch Excel, you can open a file along with it by either putting the file in the xlStart folder (look it up in Excel Help; the relevant topic is "Customize how Excel starts"), or by including the path to the file in the command line.
- Alternatively if the .xls extension is correctly associated with Excel, all you would need to do is execute a command line pointing to an .xls file. That would automatically open Excel and load the file into it.
- You can have a macro run automatically upon load by creating it in the Workbook's Workbook_Open event. (Again, all explained in Excel's Help.)

Now, before you do this and get disappointed, you may want to consider the one thing that Martin didn't mention... where exactly do you think that the batch file will run? Consequently, where do you think that the Excel session will open?

Martin is correct if you want some kind of macro to run on the server alone. But if you're expecting this to be some sort of solution which will allow the server to communicate back to the users (which you may or may not, I have no idea what it is that you're trying to do).. this is not it.

Re: Calling a Macro From TI

Posted: Fri Feb 17, 2012 9:31 am
by sg2012
Hey Alan Thanks a lot for your valuable response.

But I dont want Macro to run on opening the Excel page.
Instead i want my macro to run at the click of Action Button.

Your further guidance will be appreciated.
:)

Re: Calling a Macro From TI

Posted: Fri Feb 17, 2012 11:07 am
by Alan Kirk
sg2012 wrote:Hey Alan Thanks a lot for your valuable response.

But I dont want Macro to run on opening the Excel page.
Instead i want my macro to run at the click of Action Button.

Your further guidance will be appreciated.
:)
The button isn't a standard one, by which I mean it isn't from the Forms library or the ActiveX collection. Instead it comes from a TM1 library. That means that it doesn't have the standard events like _Click.

What it does do, though, (if that option is selected in the button's properties) is to recalculate the sheet. If you have just one volatile formula on the sheet (such as a =Now() function) and you avoid using code that causes an endless recalculation cycle, you can put code in the Worksheet_Calculate event to be triggered when the action button recalculates the sheet. This requires you to understand clearly that it will fire not once, but three times. The last time will be after the user clicks on the button confirming that the process has run successfully.

And with that, I am washing my hands of it. I have no idea why you're bound and determined to overlook at the most obvious and foolproof course of storing the relevant time in a cube, but my business is raising bridges when necessary, not lowering rivers for the hell of it.

Re: Calling a Macro From TI

Posted: Fri Feb 17, 2012 11:11 am
by lotsaram
Let's go back to the beginning.

WHAT TO YOU WANT TO ACTUALLY DO?

As in what requirement needs to be filled here? An action button lets not forget can run a TI process and a TI process can do virtually anything within a TM1 server instance that you want; move data, write new data, create objects, set users and security, ... more or less limited only to your imagination. A TI can also call a batch file or a shell command to execute other scripts which could do many things on the physical server itself; create directories, copy files, start or stop other services, ... again only limited by your imagination.

You could think of any such code that is run as being rather like a "macro" if you really want to. So what is the point here?

Re: Calling a Macro From TI

Posted: Sun Feb 19, 2012 10:14 pm
by Gregor Koch
Think the beginning is here

http://www.tm1forum.com/viewtopic.php?f ... 481#p29481

might have changed to something else in the meantime though.