Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel 2002 RTD - GetNewValues and RestartServers
Hi Stephen,
In short, yes, you are correct. I know that I can do this with the GetNewValues parameter. The wrinkle is if a user has opted not to have updates immediately and then decides to update the values in an already open workbook - how can I "restart" the RTD process to begin pulling in new values? Thanks for your reply - hope this makes sense. Christopher J. Rizzo ----------------------------------------------- (Steve Culhane [MS]) wrote in message ... Christopher, From what I've read it seams like you want to turn on and off the update through an add-in. And you want the user to be able to do this on a per workbook basis. Let me know if that's what you're looking for Stephen Culhane Microsoft Developer Support This posting is provided "AS IS" with no warranties, and confers no rights. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel 2002 RTD - GetNewValues and RestartServers
Christopher,
I was wrestling with the add-in concept, and found out that it was just not practicle. I confered with a couple of other folks here that confered with me. The problem is that the add-in has to have access to your RTD object through multiple workbooks or instances of Excel. This gets a lot more complicated, and I don't know where to start, or when I'd be finished doing a proof of concept (POC) on it. But here's another alternative. Wrap the RTD in a UDF. Use a global variable to see if you want to do the update or not. Here's a quick sample you can put in a sheet to show you what I'm talking about. With a little tweeking and tuning I think this will give you what you want. The RTD Object I'm using here is documented in MSDN under Building Excel Real-Time Data Components in Visual Basic .NET. You could uses your own or one of the KB article samples. Here a KB article with one too... HOWTO: Create a RealTimeData Server for Excel 2002 http://support.microsoft.com/?id=285339 Now the code. Add this code to an Excel Workbook Dim AllowRTD As Boolean Private Sub Workbook_Open() End Sub Private Sub Workbook_Activate() AllowRTD = False End Sub Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean) runRTD = False End Sub Public Function MyRTD(MyObject As String, Topic1 As String, Topic2 As String) As Double If AllowRTD = True Then MyRTD = Application.WorksheetFunction.RTD(MyObject, "", Topic1, Topic2) End If End Function Public Sub TurnOffRTD() AllowRTD = False End Sub Public Sub TurnOnRTD() AllowRTD = True Application.RTD.RestartServers End Sub Then in your spreadsheet go to a cell and put the call to the main UDF =MyRTD("Stock.Quote", "MSFT", "Last") or =MyRTD("Stock.Quote","MSFT", "Open") If you experiment with the TurnOffRDT and TurnOnRTD function you see that if you Wrap all your RTD calls by a function you can turn them all on and off at will. You can event put them in an XLA if you want. Let me know if this resolves this for you... Stephen Culhane Microsoft Developer Support This posting is provided "AS IS" with no warranties, and confers no rights. -------------------- | From: (Christopher Rizzo) | Newsgroups: microsoft.public.excel.programming | Subject: Excel 2002 RTD - GetNewValues and RestartServers | Date: 11 Jul 2003 12:22:01 -0700 | Organization: http://groups.google.com/ | Lines: 74 | Message-ID: | References: | NNTP-Posting-Host: 192.223.243.6 | Content-Type: text/plain; charset=ISO-8859-1 | Content-Transfer-Encoding: 8bit | X-Trace: posting.google.com 1057951322 3779 127.0.0.1 (11 Jul 2003 19:22:02 GMT) | X-Complaints-To: | NNTP-Posting-Date: 11 Jul 2003 19:22:02 GMT | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed 00.sul.t-online.de!t-onlin e.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfee d-east.nntpserve r.com!nntpserver.com!chi1.webusenet.com!news.webus enet.com!pd2nf1so.cg.shawc able.net!residential.shaw.ca!sn-xit-03!sn-xit-06!sn-xit-01!sn-xit-09!superne ws.com!postnews1.google.com!not-for-mail | Xref: cpmsftngxa06.phx.gbl microsoft.public.excel.programming:396859 | X-Tomcat-NG: microsoft.public.excel.programming | | Sounds good...I'll keep looking at it also - keep me posted. | | CJR | --------------------- | (Steve Culhane [MS]) wrote in message ... | Christopher, | I'm researching a way I think you can do it, and will get back to you | on my success or failure, ASAP. If it works I'll have sample code for you | too. | | Stephen Culhane | | Microsoft Developer Support | | This posting is provided "AS IS" with no warranties, and confers no rights. | | | | -------------------- | | From: (Christopher Rizzo) | | Newsgroups: microsoft.public.excel.programming | | Subject: Excel 2002 RTD - GetNewValues and RestartServers | | Date: 9 Jul 2003 12:09:46 -0700 | | Organization: http://groups.google.com/ | | Lines: 28 | | Message-ID: | | References: | | | NNTP-Posting-Host: 192.223.243.6 | | Content-Type: text/plain; charset=ISO-8859-1 | | Content-Transfer-Encoding: 8bit | | X-Trace: posting.google.com 1057777787 1472 127.0.0.1 (9 Jul 2003 | 19:09:47 GMT) | | X-Complaints-To: | | NNTP-Posting-Date: 9 Jul 2003 19:09:47 GMT | | Path: | cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed 00.sul.t-online.de!t-onlin | e.de!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sn-xit-03!sn-xit-06!sn- | xit-09!supernews.com!postnews1.google.com!not-for-mail | | Xref: cpmsftngxa06.phx.gbl microsoft.public.excel.programming:396125 | | X-Tomcat-NG: microsoft.public.excel.programming | | | | Hi Stephen, | | | | In short, yes, you are correct. I know that I can do this with the | | GetNewValues parameter. The wrinkle is if a user has opted not to | | have updates immediately and then decides to update the values in an | | already open workbook - how can I "restart" the RTD process to begin | | pulling in new values? | | | | Thanks for your reply - hope this makes sense. | | | | Christopher J. Rizzo | | | | | | ----------------------------------------------- | | (Steve Culhane [MS]) wrote in message | ... | | Christopher, | | From what I've read it seams like you want to turn on and off the | update | | through an add-in. And you want the user to be able to do this on a | | per workbook basis. | | | | Let me know if that's what you're looking for | | | | | | Stephen Culhane | | | | Microsoft Developer Support | | | | This posting is provided "AS IS" with no warranties, and confers no | rights. | | | |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Excel 2002 RTD - GetNewValues and RestartServers
Stephen,
The wrapper idea was good - I was using a function wrapper for RTD anyway. Here's what I did, which gives me most of the functionality I need: In the ConnectData method of my real-time data solution, I check a variable that determines if this is the first pass through this procedure. If this is true, it checks to see what value the GetNewValues parameter has being passed into the function. Under this condition a message box appears, asking users if they want to refresh data. Since an existing worksheet will always pass GetNewValues = False when re-opened, this gives the user an opportunity to refresh existing values or keep the last saved data. If they choose to keep static data, a global variable sets GetNewValues = False and all data on the worksheet will remain static (though updates will still happen behind the scenes). If the user chooses to receive refreshed data, the global variable is set to True and all data will be constantly refreshed. A side-note here is this: even on a static worksheet, if a user wants a new data item's value, they can enter the function and return a fresh value, but one that will remain static (this is because all newly entered values will have GetNewValues=True, which will override the global setting. The other place I made a change is to check the status of the global GetNewValues variable before performing an .UpdateNotify. If it's false, I skip the update - if it's true, I update away. Next thing for me to do is implement a toggle to turn this on/off at will. Given my current implementation, this should be pretty easy as my global variables could probably just become properties to the RTD component. Thanks for your help with this - let me know if you want to see some code. CJR |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Open Excel 2002 Attachment from Outlook 2002 | Excel Discussion (Misc queries) | |||
Excel 2002: How is the Excel 2007 file format open in Excel 2002 ? | Excel Discussion (Misc queries) | |||
Excel 2002 : Unable to open files in MS Outlook 2002 | Excel Discussion (Misc queries) | |||
Outlook 2002 calendar dates exported to Excel 2002 sort incorrectl | Excel Worksheet Functions | |||
Can you print labels using Excel 2002 in a Word 2002 mail merge? | Excel Discussion (Misc queries) |