Selection.Font.Bold = -1 (True) / 0 (False)
Selection.Font.Italic = -1 (True) / 0 (False)
Selection.Font.Superscript = -1 (True) / 0 (False)
Selection.Tables(1).Rows.WrapAroundText = -1 (True) / 0 (False)
Selection.Tables(1).Rows.AllowOverlap = -1 (True) / 0 (False)
ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = -1 (True) / 0 (False)
Application.ActiveWindow.View.ShadeEditableRanges = -1 (True) / 0 (False)
ActiveDocument is not always available - WIndowsModification - display shaded / protected areas ??
Creating command buttons from outside the VSTO solution
If you put creating the button "outside" the VSTO solution, then you need to be careful to set the CustomizationContext = this.InnerObject (Me.InnerObject) so that the button is specific to the VSTO document. (By default, Word will probably try to put it in Normal.dot). Pass InnerObject to the method as an argument of the Word.Document variable type.
With Word, you must consider CustomizationContext (look it up in Word's object model Help). You either add the buttons within the context of a specific document (or the template to which it is attached), or you place them in a globally loaded template. If you don't specify, the Word may put them in one place, then remove them somewhere else, or tell you it exists when, in reality it doesn't in the particular context.
VSTO can be used to customise the behaviour of a particular document or a set of documents created from a common template
Word templates in VSTO behave different to word templates with VBA code
VBA Templates - VBA code in the template and in the document can run concurrently
VSTO Templates - .NET code in the template is associated with the document when it is created. Can you have code associated with the document and more/different code associated with the template linked to that document.
F4 not repeating commands
Style Id = 2321
Autotext Id = 2205
Print Layout instead of Print View
Open Word and display the (Tools > Options)(View tab).
Should the text in brackets be changed to (Print Layout only).
Maximum Number of Undos
There is no option to change the maximum number of undos.
Although in PowerPoint it is possible (Tools > Options)(Edit tab, "Maximum number of undo").
Inconsistent Shortcut Keys
In Excel both these shortcuts close all workbooks and not just the active one.
(Alt + F4) - Closes the active document (saving first) and the exits Word if it is the last document.
(Alt + Shift + F4) - Closes the active document (saving first) and the exits Word if it is the last document.
Ruler cannot be toggled
It is only possible to toggle the display of the ruler from (View > Ruler) when there is an open document
Is there any reason for this ?
The following Properties should be added
The following properties should be added to the Selection object instead of having to use the Range property.
Selection.Range.Bold = False
Selection.Bold = False
The following Methods should be added
Word Normal Changes
If you create "temporary" commands from VBA there is no "changes to Normal" prompt.
However if you create any "temporary" commands from .NET add-ins there is a "changes to normal" prompt.
In Word 2002 and Word 2003 the Normal.dot is not automatically created when Word is opened as was the case in the previous versions.
In both these versions the Normal.dot may or may not actually exist.
If the Normal.dot template does not exist then the following message will be displayed the first time Word is opened.
Any changes to the toolbars & menus are automatically stored in the Normal.dot template.
This creates a real problem and the only way round it is to explicitly not save these changes.
To confuse the issue even more the (Tools > COM Add-ins) command needs to be permanently added.
There are two places where you must add additional code:
Public Sub App_Startup()
If clsTemplate.NormalExists(True) = True Then
If clsTemplate.NormalSavedGet = False Then
If clszMessagesWord.NormalTemplateSaveChangesBeforeQuestion = True Then
Public Sub App_Shutdown()
If clsTemplate.NormalExists = True Then
If clsTemplate.NormalSavedGet = False Then
'changes have been made while the add-in was installed
'therefore automatically save or prompt depending on user's option
Explicit Datatype Conversion
Dim objStyle As Word.Style
objStyle = CType(Application.Selection.Style, Word.Style)
Dim objTemplate As Word.Template
objTemplate = CType(Application.ActiveDocument.AttachedTemplate, Word.Template)
The following line returns 0 in VBA
The following line returns -1 in VSTO
Word.wdColor = RGB( ??
Installing the Add-in
The first time an add-in is installed and loaded the following dialog box will be displayed.
The change that this refers to is the adding of the COM Add-ins command to the Tools drop-down menu.
This command gives you access to all your COM Add-ins and should be permanently added to your Menu Bar.
The toolbar and menu changes that are then made are not saved to your Normal.dot.
If you want to make any manual changes to your toolbars and menus then you should do this before loading the add-in.
Making manual toolbar & menu changes
Select (Tools > COM Add-ins) and unselect any of the Better Solutions add-ins.
Close and exit Word.
Open Word and make your changes to the toolbars and menus.
Select (Tools > COM Add-ins) and select the Better Solutions add-ins.
The above prompt will be displayed again and this will refer to the manual changes you have just made.
Do not make any manual changes to the toolbars and menus while a Better Solutions add-in is installed.
You are unable to change the order of the windows if you create a new document when you have a windows form displayed
This only happens when the (Tools > Options)(View tab, "Windows in Taskbar") is selected.
Bug - Visual Studio 2008
Word 2007 add-in
error "cannot access a disposed object" - smarttags ??
You need to use the ApplicationEvents4_Event interface and the DocumentEvents2_Event interface
When you want to define an event using the Application or Document objects.
This casting must be done when you declare any events, not just ones that have a conflicting method and event name
app.DocumentBeforeClose += new Word.ApplicationEvents4_DocumentBeforeCloseEventHandler(App_DocumentBeforeClose);
Call CType(gApplication, Word._Application).Quit()
public void Event_ApplicationNewDocument
((Word.ApplicationEvents4_Event)application).NewDocument += new Word.ApplicationEvents4_NewDocumentEventHandler(Event_ApplicationNewDocument);
public void Event_DocumentClose
((Word.DocumentEvents2_Event)doc).Close += new Word.DocumentEvents2_CloseEventHandler(Event_DocumentClose)
© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext