|
|
Rank: Newbie Groups: Member
Joined: 11/17/2010 Posts: 2 Location: Belo Horizonte, Brasil
|
Hello everybody.
I have been lurking the forum for some time and it is indeed a great source of information.
Recently I have come in contact with a legacy Excel spreadsheet that uses some Datalink functionalities. This spreadsheet was developed apparently with no SDK in mind, and therefore make heavy use of Datalink formulas, specially "=PIAdvCalcDat". First the former developer defined some formulas in certain cells and after that used "Application. Run "ShowAdvCalcDat"" to bring the Datalink "Advanced Calculated Data" Form. This Form comes already correctly filled and requires the user to click the OK button so the VBA code can continue to run and correctly fetch data and fill the cells.
I know that using PISDK would avoid the Form from popping up and requesting user input to continue, everything would run in the background. The thing is that it is a big code with no traces of PISDK in it. What I am wondering is if it is possible to use "Application.Run "ShowAdvCalcDat"", accept the default values that are shown in the input boxes of the Form and then continuing the execution of the rest of the code automatically without the need for the user to click the OK button.
This would be the simpler way to do it. If it is not possible, we may have to start translating everything to SDK functions that will produce the same effect.
I have tried using SendKeys"{ENTER}" but the code halts at the Application.Run line and will not continue unless I click the OK button. I also thought of a way of calling the PIAdvCalcDat with the equivalent parameters, but could not do it properly.
I hope I have made myself clear about it. Let me know if you need further explanation, I may be able to study the spreadsheet in more depth as the issue is developed.
Thank you very much.
Best regards.
|
|
|
|
|
OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System. We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ or contact OSIsoft vCampus for more details.
|
|
|
Rank: Advanced Member Groups: Member
Joined: 5/28/2009 Posts: 75 Location: Cheshire, UK
|
Daniel, I use: Code:Application.Run("PISampDat", tag, start-time, end_time, "1800s", , pi_server) and this happily returns values (i.e. it does not insert a formula) to the sheet with further user intervention. Unfortunately Macro Recorder does not actually record the building of PI formulas - at least not for me anyway. regards, milesUK MilesUK ProcessBook v3.0.15.3
|
|
|
Rank: Newbie Groups: Member
Joined: 11/17/2010 Posts: 2 Location: Belo Horizonte, Brasil
|
Hi, Miles. I was about to post a follow-up here. I had more time to play with the code and understand it better and decided to follow the path of using a function and passing parameters to it, so I could treat the result. Turns out a typo in the parameters of the function was causing problems. My bad. I thought this was not working as expected. Well. Thanks for your answer. This is a nice solution, and apparently it is fine for the current user if only the values are presented to him (not formulas, as you stated in your post). Regards.
|
|
|
Rank: Advanced Member Groups: Member
Joined: 5/28/2009 Posts: 75 Location: Cheshire, UK
|
Daniel, glad you are sorted. My post should of course have read "and this happily returns values (i.e. it does not insert a formula) to the sheet with NO further user intervention." miles MilesUK ProcessBook v3.0.15.3
|
|
|
|
Guest
|