logo

Response

« Return to the main article

You are viewing this page out of context. To see it in the context it is intended please click here.

About This Page

Reply posted by Mike Golding on Thu 20 Dec 2001 in response to Keeping the boss happy

Doing this Using Web Components

N.B. To use web components you need IE5+, Office 2000/XP (to develop) or XP
Components for viewing. XP Components version 10 are available for download at
Microsoft.com if you have clients without office 2000+.


http://office.microsoft.com/downloads/2002/owc10.aspx?HelpLCID=%HelpLang%1033




As I pointed out the original example in this thread launches excel in-place
and doesn't use Web Components as some have suggested. So I have dug out an
example of how to do the same thing (or similar) using components. Using
components has several advantages and disadvantages but there is one very nice
feature... read on.



Firstly: i'll reproduce the "Hello Excel" example using the excel web
component. Use the following print statements in an agent and call the agent
from the web. The agent name can be anything and does not require the .xls name
as you are not trying to get a full blow Excel session running.



Print {<object id=component1 classid=CLSID:0002E510-0000-0000-c000-000000000046
style="width:49%;height:350"></object>}


Print {<script language=vbscript>}
Print {dim osheet}
Print {set osheet = component1.ActiveSheet}
Print {osheet.range("A1:A1").Value = "Hello Excel Web Component"}
Print {</script>}




This launches the default component and sets the first cell value. The first
line embeds the component (an activeX control) using its class ID. If the
machine loading the page does not have the component registered (i.e.
installed) the activeX control will not display. There are many many ways to
configure the component once it has loaded e.g.


Print {component1.TitleBar.Caption = "This is a CodeStore test"}


check out the MSOffice VBA component documentation for a full method reference.



So whats the advantage? Well you can format the page around the component for
one and the component is light-weight but a major advantage is the DataType
property of the sheet component. This property has a type of HTMLURL, sounds
interesting, and in operation it is amazingly simple!!!


Print {component1.HTMLURL = "url to data"}


Heres the cruncher... Just set the URL to a Notes View and your view will
appear in the component!!! The code is below.



Print {osheet.cells.clear}
Print {component1.DataType = "HTMLURL"}
Print {component1.HTMLURL = "/my database/myview?OpenView"}



However there are some caveats. The URL must be to the same sever that the
component is loaded from, i.e. the same server as the database that is running
your agent. And the view must have no formatting. The best way to do this is to
create a view template for the view and have nothing in it but a $$ViewBody
field.


Doing this is similar to doing a "New Web Query" from within Excel.



Well... there you go... simple... and the automation possibilities are huge.
Mix this with the pivot table and chart components and the boss will be really
happy.


Make good use of it...!!



Mike
http://www.notestips.com