Topaz Filer: if you use e-mail for business, we can save you money and decrease your risk.
Passing parameters to a VSTO document?
Messages   Related Types
This message was discovered on microsoft.public.vsnet.vstools.office.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Rohan Cragg via .NET 247 (VIP)
GOOD ANSWER
http://dotnetjunkies.com/WebLog/rohancragg

As you will see from my first blog entry, I have been playing with VSTO and loving it. My one big question which I can't seem to get my head round is as follows.

I already know I can open a new document from a template and run some code (with VSTO), but is there any way I could possibly pass in a parameter from somewhere so that code-behind can fill some relevant data for me.

The example scenario would be that I have a page on the CRM section of our intranet showing a client's details, and I want to provide a 'new letter to this client' hyperlink. I could write a winforms app hosted in IIS to act as a go-between and pick the parameter up from the QueryString but is there a better way where I can stay within the VSTO way of doing things?

--------------------------------
From: Rohan Cragg

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>p8hwB7EqE0KOqDrLXxMajg==</Id>
Reply to this message...
Vote that this is a GOOD answer... (9 votes from other users already)
 
 
    
Iouri Simernitski (MS)
GOOD ANSWER
Hi Rohan,
welcome to VSTO!

This kind of solution was implemented in the Estimates VSTO sample where
Excel invokes Word and passes data to it. Both Excel and Word use VSTO
code-behind.
The approach used there was to create a word document, set custom
properties and call document.Activate. In the Word document's code-behind,
the Open event only hooks up the Activate event. The handler for Activate
has all the actual processing (and also unhooks itself, so that the code is
only run on the first Activate).

In your case, I would automate Word through client-side scripting (JScript
or VBScript). Putting a hyperlink to a Word project not only makes it hard
to pass data (because no code runs to push the data to Word), but has other
limitations - see recent thread "REPOST: Code behind events are not firing"
for more details. You will also notice that word does not accept templates
that have HTTP addresses. You will have to either implement your template
as a document or access it through UNC (e.g. \\myserver\share\file.dot).

Hope this helps,
iouri

----------
This posting is provided "AS IS" with no warranties, and confers no rights.

Reply to this message...
Vote that this is a GOOD answer... (9 votes from other users already)
 
 
    
Nancyb
GOOD ANSWER
Hi Iouri,
This seems like a silly question, but where can I find the files for this sample?
I found the link to the Estimates sample...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_wrcore/html/wroriendtoendsolutionsample.asp
....but now don't know where to find the 'Sample Files box' that it says I need to click. This is what it says in the 'To build the sample' section. "In the Sample Files box in this topic, click Copy All Files and specify where you want to save the files."

Thanks in advance. I'd really like to try out this sample.

Reply to this message...
Vote that this is a GOOD answer... (8 votes from other users already)
 
 
    
Howard Kaikow
GOOD ANSWER
The Estimates Sample description and files are in the MSDN library that was
installed with VS .NET 2003.
Appears to need a Web Server to load the solution.

--
http://www.standards.com/; See Howard Kaikow's web site.
"Nancyb" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

"In the Sample Files box in this topic, click Copy All Files and specify
where you want to save the files."
[Original message clipped]

Reply to this message...
Vote that this is a GOOD answer... (8 votes from other users already)
 
 
 




Ad
BootFX
Reliable and powerful .NET application framework.
Recession Busting Bespoke Software
Get through the recession by investing in bespoke software to decrease costs and create commercial opportunities.
Other DN247 Network Sites
.NET 247
SQL Server Wins
Old Skool Developer
 
Copyright © AMX Software Ltd 2008-2009. Portions copyright © Matthew Baxter-Reynolds 2001-2009. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - .NET 247 is a member of the DN247 Network - 4.0.30129.1734