|
Angel Yuan [MSFT] (Moderator):
Hello India MVPs, I am Angel Yuan, the MVPAA Manager for Asia
Pacific and Greater China Region, MVP and Technical Communities.
Nice to meet you all here.
Naresh_MVP (Expert):
Hi
Angel and Hi everyone
Angel Yuan [MSFT] (Moderator):
I
will be the moderator for the Chat today, please feel free to
message me if you encounter any problems. Chat Topic for today:
Visual Studio Tool for Office 2005 and the Expert is Naresh Nichani,
let's welcome him and get started! Fire away with your questions for
Naresh.
Angel Yuan [MSFT] (Moderator):
To
submit a question for our hosts to answer, please check the "Ask the
Experts" box, then click "Send", this way we can get them in the
queue to answer. If you just want to add a comment to the chat
window, remain the "Ask the Experts" box unchecked.
Naresh_MVP (Expert):
Would you guys like to do mainly Q&A or would you like me to first
give a breif talk on VSTO?
Naresh_MVP (Expert):
Ok
lets get started
Naresh_MVP (Expert):
VSTO in 2005 is greatly improved from 2003 and we can do Office dev
a whole lot better now
Naresh_MVP (Expert):
VST0 2005 supports Word 2003, Excel 2003, Outlook 2003 and
InfoPath2003
Naresh_MVP (Expert):
Earlier we just had Word 2003 and Excel 2003
Naresh_MVP (Expert):
However users must have the Office System 2003 (earlier versions of
Office are not supported for VSTO)
Naresh_MVP (Expert):
To
learn more on VSTO I suggest you look here
Naresh_MVP (Expert):
http://msdn.microsoft.com/office/understanding/vsto/default.aspx?pull=/library/en-us/odc_vsto2005_ta/html/officewhatsnewinvsto2005.asp
Naresh_MVP (Expert):
This gives a good overall idea of VSTO in simple terminology
Naresh_MVP (Expert):
No
not even Office XP
Naresh_MVP (Expert):
The
advantage of VSTO is we can use the .Net Framework 2.0 with the
power of Office
Naresh_MVP (Expert):
The
.Net Framework 2.0 is very powerful and when combined with Office
you can build some great solutions for your customers
Naresh_MVP (Expert):
You
can create VSTO projects in VS 2005 with the New Project Option -
here along with "Windows", "Smart Office" there is a new "Office"
option
Naresh_MVP (Expert):
The
Office option has some project templates for Word, Excel and Outlook
projects
Naresh_MVP (Expert):
let
us say for example you create a Excel workbook project
Naresh_MVP (Expert):
This can be created based on a existing workbook or a new workbook
Naresh_MVP (Expert):
In
an Excel VSTO solution each worksheet can have a code behind page
and behaves like a "Windows Form"
Naresh_MVP (Expert):
The
VS 2005 designer will merge the Excel interface and VS 2005 menus
and command bars for you to make it seamless
Naresh_MVP (Expert):
You
can work with all Excel functions - enter data in cells, format
cells, add worksheets etc and also write code behind in the same
environment
Naresh_MVP (Expert):
You
can even place Windows Forms controls on the Excel sheets and write
code behind for the Windows Forms controls
Naresh_MVP (Expert):
So
I could a Windows Forms button or List view to a Excel sheet or Word
document and write code in the code behind by double clicking
control
Naresh_MVP (Expert):
A
new feature of VSTO 2005 is Host Controls
Naresh_MVP (Expert):
Host Controls are speicifc to Excel and Word
Naresh_MVP (Expert):
For
example
Naresh_MVP (Expert):
In
Excel we have a Host Control called "NamedRange"
Naresh_MVP (Expert):
When you are working in a Excel VSTO 2005 project you will see "NamedRange"
in the Toolbox
Naresh_MVP (Expert):
When you drop it on a Excel sheet you will asked for a range address
Naresh_MVP (Expert):
So
say you create a namedrange called "MyCustomers" - you can double
click and do code behind for this range only
Naresh_MVP (Expert):
This is not possible in Excel VBA
Naresh_MVP (Expert):
In
Excel VBA you cannot define a range and write specifically for that
range
Naresh_MVP (Expert):
In
a similar way in Word you have a HostControl called "Bookmark"
Naresh_MVP (Expert):
A
bookmark is a deisgnated area of a Word document - you can drop this
control in your Word document and trap changes there only and not
the full document
Naresh_MVP (Expert):
Before I go further any questions on HostControls on general VSTO
concepts?
Naresh_MVP (Expert):
Ok
guys will go ahead
Naresh_MVP (Expert):
Another very nice feature of VSTO 2005 is Smart Tag development
which is hugely simplified
Naresh_MVP (Expert):
Smart Tags are the small icons which appear on top your document and
you can perform some action with them
Naresh_MVP (Expert):
Witth VSTO 2005 it is very easy to build them - earlier it was
fairly complex
Naresh_MVP (Expert):
In
VSTO 2005 Smart tags are specific to your solution - they are not
global to all Word docs or all Excel spreadsheets
Naresh_MVP (Expert):
So
you can build a Smart tag in Word to look for the tag "Sensex" and
perform some action
Naresh_MVP (Expert):
Here is a code sample for this
Naresh_MVP (Expert):
#Region "Smart Tag Example"
WithEvents DisplayAddress As Microsoft.Office.Tools.Word.Action
Private Sub AddSmartTag()
Dim SmartTagDemo As New _
Microsoft.Office.Tools.Word.SmartTag( _
"www.microsoft.com/Demo#DemoSmartTag", _
"Demonstration Smart Tag")
' Specify the terms to recognize.
SmartTagDemo.Terms.Add("term")
SmartTagDemo.Terms.Add("recognize")
Naresh_MVP (Expert):
' Create the action.
DisplayAddress = New _
Microsoft.Office.Tools.Word.Action( _
"To be replaced")
' Add the action to the smart tag.
SmartTagDemo.Actions = New _
Microsoft.Office.Tools.Word.Action() { _
DisplayAddress}
' Add the smart tag to the document.
Me.VstoSmartTags.Add(SmartTagDemo)
End Sub
Naresh_MVP (Expert):
Sub OpenMessageBox_BeforeCaptionShow(ByVal sender As Object, _
ByVal e As Microsoft.Office.Tools.Word.ActionEventArgs) _
Handles DisplayAddress.BeforeCaptionShow
DisplayAddress.Caption = "Display the location of " & _
e.Text
End Sub
Sub DisplayAddress_Click(ByVal sender As Object, _
ByVal e As Microsoft.Office.Tools.Word.ActionEventArgs) _
Handles DisplayAddress.Click
Dim termStart As Integer = e.Range.Start
Naresh_MVP (Expert):
Oops sorry that is not fitting easily
Naresh_MVP (Expert):
Hold on one sec
Naresh_MVP (Expert):
More info here on Smart tag development
Naresh_MVP (Expert):
o More here -
http://msdn2.microsoft.com/library/ms178786(en-us,vs.80).aspx
Naresh_MVP (Expert):
No
no handheld devices yet here - this is Office 2003 for the desktop
right now - Word, Excel Outlook and Infopath only
Naresh_MVP (Expert):
Back to smart tags
Naresh_MVP (Expert):
WithEvents DisplayAddress As Microsoft.Office.Tools.Word.Action
Private Sub AddSmartTag()
Dim SmartTagDemo As New _
Microsoft.Office.Tools.Word.SmartTag( _
"www.microsoft.com/Demo#DemoSmartTag", _
"Demonstration Smart Tag")
' Specify the terms to recognize.
SmartTagDemo.Terms.Add("term")
SmartTagDemo.Terms.Add("recognize")
Naresh_MVP (Expert):
This code will basically allow you to Smart tag the word word "term"
and "recognize"
Naresh_MVP (Expert):
Anyway these words appear in your solution a smart tag will appear
Naresh_MVP (Expert):
' Create the action.
DisplayAddress = New _
Microsoft.Office.Tools.Word.Action( _
"To be replaced")
' Add the action to the smart tag.
SmartTagDemo.Actions = New _
Microsoft.Office.Tools.Word.Action() { _
DisplayAddress}
' Add the smart tag to the document.
Me.VstoSmartTags.Add(SmartTagDemo)
End Sub
Naresh_MVP (Expert):
This code basically adds teh smart to the solution (complete of
prior code)
Naresh_MVP (Expert):
This code executes when the smart tag is clicked
Naresh_MVP (Expert):
Sub
DisplayAddress_Click(ByVal sender As Object, _
ByVal e As Microsoft.Office.Tools.Word.ActionEventArgs) _
Handles DisplayAddress.Click
Dim termStart As Integer = e.Range.Start
Dim termEnd As Integer = e.Range.End
MsgBox("The recognized text '" & e.Text & _
"' begins at position " & termStart & _
" and ends at position " & termEnd)
End Sub
Naresh_MVP (Expert):
Here in Word it prints where the Word exists in Word doc - however
you could check for things like Stock Ticker or Customer Info and
link to a CRM system etc
Naresh_MVP (Expert):
Sorry it cannot be viewed on handhelds
Naresh_MVP (Expert):
To
know more on Smart tag refer here
Naresh_MVP (Expert):
o
http://msdn2.microsoft.com/library/ms178786(en-us,vs.80).aspx
Naresh_MVP (Expert):
My
next topic is Action Panes
Naresh_MVP (Expert):
In
Office 2003 all of you have seen the Task Pane
Naresh_MVP (Expert):
This is docked window normally on right and you can do Styles,
Revisions and all kinds of nice things
Naresh_MVP (Expert):
However with VBA you cannot create your own task pane
Naresh_MVP (Expert):
However with VSTO you can write to a special task pane called the
"Action Pane" and place a Windows forms controls there
Naresh_MVP (Expert):
Task Panes contain Windows Forms controls. You can
also add “User Controls” which can be combination of many Windows
forms controls
Naresh_MVP (Expert):
So
how we develop the Action pane for our solution and display in Word
or Excel
Naresh_MVP (Expert):
§ Open your Word/Excel project in Visual Studio.
§ On the Project menu, click Add New Item.
§ In the Add New Item dialog box, select Actions Pane
Control, name it HelloControl and click Add.
Naresh_MVP (Expert):
The
Word and Excel projects have a special item you can add to project
called "Action Pane"
Naresh_MVP (Expert):
Give the ActionPane a name and open from Solution Explorer
Naresh_MVP (Expert):
Here you can drop Windows Forms or your User controls
Naresh_MVP (Expert):
Yes
Naresh_MVP (Expert):
Word and Excel have Task Panes - you can create a special one for
your solution with VSTO
Naresh_MVP (Expert):
Add
the following code to ThisDocument_Startup to activate the Action
Pane you amde
Naresh_MVP (Expert):
Dim
hello As New HelloControl
Me.ActionsPane.Controls.Add(hello)
Naresh_MVP (Expert):
This assumes HelloControl is the name of the ActionPane you just
made
Naresh_MVP (Expert):
The
Action Pane can have Windows Forms control and code behind and
interact with your solution
Naresh_MVP (Expert):
For
example assume you had a button on the Action Pane
Naresh_MVP (Expert):
This can be code behind for the button
Naresh_MVP (Expert):
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) _
Handles Button1.Click
Globals.ThisDocument.Paragraphs(1).Range.Text = "Hello world!"
End
Sub
Naresh_MVP (Expert):
The
Global.ThisDocument refers to the word document in your solution
Naresh_MVP (Expert):
<http://msdn2.microsoft.com/library/7we49he1(en-us,vs.80).aspx>
Naresh_MVP (Expert):
To
know more on Action Panes in VSTO
Naresh_MVP (Expert):
You
can also make the Action Pane change as user moves to different
parts of your document
Naresh_MVP (Expert):
For
example user is in a area where they can change logo - you can have
button "Insert Logo"
Naresh_MVP (Expert):
If
user in a table you can have options to format table or sum table
cols
Naresh_MVP (Expert):
To
learn how to do this
Naresh_MVP (Expert):
<http://msdn2.microsoft.com/library/zbxt1ax4.aspx>
Naresh_MVP (Expert):
This article shows you how to customize the action pane to diferent
parts of your document/spreadsheet
Naresh_MVP (Expert):
Now
the last topic is Deployment
Naresh_MVP (Expert):
Deploying VSTO solutions is a little tricky and you need to ship the
document/spreadsheet and the .Net assembly
Naresh_MVP (Expert):
The
.Net assembly needs "Full Trust" to execute
Naresh_MVP (Expert):
o Deploying a basic Visual Studio 2005 Tools for Office
Word or Excel solution generally means working with four files:
o
§ The Word or Excel file (template, document, or
workbook) that the end user works in
§ The assembly that contains your compiled custom code
and any dependent assemblies such as resources, satellites, or
helper libraries
§ The deployment manifest
§ The application manifest
Naresh_MVP (Expert):
This can get confusing
Naresh_MVP (Expert):
The
best way to do this is to read this blog
Naresh_MVP (Expert):
o
http://blogs.msdn.com/vsto2/archive/2005/10/11/479825.aspx
Naresh_MVP (Expert):
This gives a very simple way to deploy VSTO solutions which I found
very useful
Naresh_MVP (Expert):
The
MSDN articles for more info are at
Naresh_MVP (Expert):
o
http://msdn2.microsoft.com/library/hesc2788(en-us,vs.80).aspx
Naresh_MVP (Expert):
The
system you deploy to must have Office 2003 SP1 or later, .Net
framework 2.0 and the VSTO assembly needs full turst to execute
there
Naresh_MVP (Expert):
At
this point I am open to Q&A
Naresh_MVP (Expert):
You
can package it with your build
Naresh_MVP (Expert):
or
have users download it
Naresh_MVP (Expert):
It
does not come as a update as yet
Naresh_MVP (Expert):
Just like deploying any .Net 2.0 solution you need the framework on
user computer
Naresh_MVP (Expert):
This can be part of install or user can download indepenently
Naresh_MVP (Expert):
For
those of you bulding solutions in Office you must check this out as
VSTO does a lot VBA cannot
Naresh_MVP (Expert):
No
this is different from VBA
Naresh_MVP (Expert):
You
write in VS 2005
Naresh_MVP (Expert):
It
works with Office 2003 SP1 and later
Naresh_MVP (Expert):
VBA
can access .Net framework with COM Interop
Naresh_MVP (Expert):
However here you work with Word/Excel Interop assemblies directly
from VS 2005
Naresh_MVP (Expert):
This is more efficient
Naresh_MVP (Expert):
Office 2003 should install .net programmability support
Naresh_MVP (Expert):
This provides access to Office Object model to .Net assembly
Naresh_MVP (Expert):
VBA
also has access to Office object model just like .Net assembly
Naresh_MVP (Expert):
The
assmebly needs Full Trust on local computer and has all the security
feature of .Net framework
Naresh_MVP (Expert):
It
will not just run automatically
Naresh_MVP (Expert):
Sorry got cut off
Naresh_MVP (Expert):
serperately
Naresh_MVP (Expert):
They are not embedded in doc
Naresh_MVP (Expert):
Doc
has a special area to store code extensions
Naresh_MVP (Expert):
Take a look at
Naresh_MVP (Expert):
They can be added or removed
Naresh_MVP (Expert):
http://msdn2.microsoft.com/en-us/library/8fza57cs.aspx
Naresh_MVP (Expert):
THis tells you how to remove custom extensions when VSTO has added
them
Naresh_MVP (Expert):
Any
other questions?
Naresh_MVP (Expert):
Feel free to ping me at NareshNichani AT MVPS.org
Angel Yuan [MSFT] (Moderator):
Thank you very much for all of your participation. It’s the end of
today’s chat. Thank you Naresh. Thank you India MVPs.
Naresh_MVP (Expert):
Yes
you do
Naresh_MVP (Expert):
Thanks everybody
Agel
Yuan [MSFT] (Moderator):
Have a nice evening. :-)
Naresh_MVP (Expert):
Thanks all again - have a nice evening |