C# Snippets
CrossReference
public void Dialogs_CrossReference()
{
try
{
Tracer_Add2("SUBROUTINE", System.Reflection.MethodBase.GetCurrentMethod().Name + " start");
if (My.Settings.ERROR_OCCURRED == true)
return;
// http://support.microsoft.com/kb/175998
// http://support.microsoft.com/default.aspx?scid=kb;en-us;209668
{
var withBlock = gApplicationWord.Dialogs(Word.WdWordDialog.wdDialogInsertCrossReference);
// .ReferenceType = "Figure"
// .Referencekind = Word.WdReferenceKind.wdNumberFullContext
System.Windows.Forms.SendKeys.Send("ff {TAB} {DOWN} {TAB}");
withBlock.Show();
}
}
catch (Exception ex)
{
modMessages.Exception(System.Reflection.MethodBase.GetCurrentMethod(), null/* TODO Change to default(_) if this is not a reference type */, ex);
}
}
Public Sub Dialogs_CrossReference()
Try
Call Tracer_Add2("SUBROUTINE", System.Reflection.MethodBase.GetCurrentMethod.Name & " start")
If My.Settings.ERROR_OCCURRED = True Then Exit Sub
'http://support.microsoft.com/kb/175998
'http://support.microsoft.com/default.aspx?scid=kb;en-us;209668
With gApplicationWord.Dialogs(Word.WdWordDialog.wdDialogInsertCrossReference)
'.ReferenceType = "Figure"
'.Referencekind = Word.WdReferenceKind.wdNumberFullContext
System.Windows.Forms.SendKeys.Send("ff {TAB} {DOWN} {TAB}")
.Show()
End With
Catch ex As System.Exception
Call modMessages.Exception(System.Reflection.MethodBase.GetCurrentMethod, Nothing, ex)
End Try
End Sub
DocEvents_Close
private void DocEvents_Close()
{
if (mbFireEvents == true)
DocEventsClose_Event?.Invoke();
}
Private Sub DocEvents_Close() Handles DocEvents2.Close
If mbFireEvents = True Then
RaiseEvent DocEventsClose_Event()
End If
End Sub
DocEvents_New
private void DocEvents_New()
{
if (mbFireEvents == true)
DocEventsNew_Event?.Invoke();
}
Private Sub DocEvents_New() Handles DocEvents.New
If mbFireEvents = True Then
RaiseEvent DocEventsNew_Event()
End If
End Sub
DocEvents_Open
private void DocEvents_Open()
{
if (mbFireEvents == true)
DocEventsOpen_Event?.Invoke();
}
Private Sub DocEvents_Open() Handles DocEvents.Open
If mbFireEvents = True Then
RaiseEvent DocEventsOpen_Event()
End If
End Sub
DocumentBeforeClose
public void AppEvents_DocumentBeforeClose(Word.Document Doc, ref bool Cancel)
{
if (mbFireEvents == true)
AppEventsDocumentBeforeClose_Event?.Invoke(Doc, Cancel);
}
Public Sub AppEvents_DocumentBeforeClose(ByVal Doc As Word.Document, _
ByRef Cancel As Boolean) _
Handles AppEvents.DocumentBeforeClose
If mbFireEvents = True Then
RaiseEvent AppEventsDocumentBeforeClose_Event(Doc, Cancel)
End If
End Sub
DocumentBeforePrint
public void AppEvents_DocumentBeforePrint(Word.Document Doc, ref bool Cancel)
{
if (mbFireEvents == true)
AppEventsDocumentBeforePrint_Event?.Invoke(Doc, Cancel);
}
Public Sub AppEvents_DocumentBeforePrint(ByVal Doc As Word.Document, _
ByRef Cancel As Boolean) _
Handles AppEvents.DocumentBeforePrint
If mbFireEvents = True Then
RaiseEvent AppEventsDocumentBeforePrint_Event(Doc, Cancel)
End If
End Sub
DocumentBeforeSave
public void AppEvents_DocumentBeforeSave(Word.Document Doc, ref bool SaveAsUI, ref bool Cancel)
{
if (mbFireEvents == true)
AppEventsDocumentBeforeSave_Event?.Invoke(Doc, SaveAsUI, Cancel);
}
Public Sub AppEvents_DocumentBeforeSave(ByVal Doc As Word.Document, _
ByRef SaveAsUI As Boolean, _
ByRef Cancel As Boolean) _
Handles AppEvents.DocumentBeforeSave
If mbFireEvents = True Then
RaiseEvent AppEventsDocumentBeforeSave_Event(Doc, SaveAsUI, Cancel)
End If
End Sub
DocumentChange
public void AppEvents_DocumentChange()
{
if (mbFireEvents == true)
AppEventsDocumentChange_Event?.Invoke();
}
Public Sub AppEvents_DocumentChange() Handles AppEvents.DocumentChange
If mbFireEvents = True Then
RaiseEvent AppEventsDocumentChange_Event()
End If
End Sub
DocumentOpen
public void AppEvents_DocumentOpen(Word.Document Doc)
{
if (mbFireEvents == true)
AppEventsDocumentOpen_Event?.Invoke(Doc);
}
Public Sub AppEvents_DocumentOpen(ByVal Doc As Word.Document) _
Handles AppEvents.DocumentOpen
If mbFireEvents = True Then
RaiseEvent AppEventsDocumentOpen_Event(Doc)
End If
End Sub
Finalize
~SurroundingClass()
{
base.Finalize();
gApplicationWord = null;
gErrorWord = null;
gCmdBarWord = null;
}
Protected Overrides Sub Finalize()
MyBase.Finalize()
gApplicationWord = Nothing
gErrorWord = Nothing
gCmdBarWord = Nothing
End Sub
FormFeldsReplaceFieldsWithParameters
public static string[,] FormFeldsReplaceFieldsWithParameters()
{
// this is to get around a known MSFT bug KB 286841
try
{
if (clsError.ErrorFlag() == true)
return;
Word.FormField objFormField;
string[,] arFormFieldsArray;
System.Int32 iTextFormCount;
var oldArFormFieldsArray = arFormFieldsArray;
arFormFieldsArray = new string[3, gApplicationWord.ActiveDocument.FormFields.Count - 1 + 1];
// Redim array to hold contents of text field.
if (oldArFormFieldsArray != null)
for (var i = 0; i <= oldArFormFieldsArray.Length / oldArFormFieldsArray.GetLength(1) - 1; ++i)
Array.Copy(oldArFormFieldsArray, i * oldArFormFieldsArray.GetLength(1), arFormFieldsArray, i * arFormFieldsArray.GetLength(1), Math.Min(oldArFormFieldsArray.GetLength(1), arFormFieldsArray.GetLength(1)));
foreach (var objFormField in gApplicationWord.ActiveDocument.FormFields)
{
switch (objFormField.Type)
{
case object _ when Word.WdFieldType.wdFieldFormTextInput:
{
arFormFieldsArray[0, iTextFormCount] = "Text";
arFormFieldsArray[1, iTextFormCount] = objFormField.Result;
arFormFieldsArray[2, iTextFormCount] = objFormField.Name;
// Select the form field and replace it with placeholder text.
objFormField.Select();
gApplicationWord.Selection.TypeText("");
iTextFormCount = iTextFormCount + 1;
break;
}
case object _ when Word.WdFieldType.wdFieldFormCheckBox:
{
arFormFieldsArray[0, iTextFormCount] = "Checkbox";
arFormFieldsArray[1, iTextFormCount] = System.Convert.ToHexString(objFormField.CheckBox.Value);
arFormFieldsArray[2, iTextFormCount] = objFormField.Name;
// Select the form field and replace it with placeholder text.
// objFormField.Select()
// gApplicationWord.Selection.TypeText("")
iTextFormCount = iTextFormCount + 1;
break;
}
default:
{
break;
}
}
}
var oldArFormFieldsArray = arFormFieldsArray;
arFormFieldsArray = new string[3, iTextFormCount - 1 + 1];
// Redim array to hold the exact number of text form fields
if (oldArFormFieldsArray != null)
for (var i = 0; i <= oldArFormFieldsArray.Length / oldArFormFieldsArray.GetLength(1) - 1; ++i)
Array.Copy(oldArFormFieldsArray, i * oldArFormFieldsArray.GetLength(1), arFormFieldsArray, i * arFormFieldsArray.GetLength(1), Math.Min(oldArFormFieldsArray.GetLength(1), arFormFieldsArray.GetLength(1)));
FormFeldsReplaceFieldsWithParameters = arFormFieldsArray;
}
catch (Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
if (gbDEBUG_WORD == true | ((!mobjCOMException == null) | (!mobjException == null)))
clsError.Handle("FormFeldsReplaceFieldsWithParameters", msCLASSNAME, "replace all the form fields with equivalent parameters.", mobjCOMException, mobjException);
}
}
Public Shared Function FormFeldsReplaceFieldsWithParameters() As String(,)
'this is to get around a known MSFT bug KB 286841
Try
If clsError.ErrorFlag() = True Then Exit Function
Dim objFormField As Word.FormField
Dim arFormFieldsArray As String(,)
Dim iTextFormCount As System.Int32
' Redim array to hold contents of text field.
ReDim Preserve arFormFieldsArray(2, gApplicationWord.ActiveDocument.FormFields.Count - 1)
For Each objFormField In gApplicationWord.ActiveDocument.FormFields
Select Case objFormField.Type
Case Word.WdFieldType.wdFieldFormTextInput
arFormFieldsArray(0, iTextFormCount) = "Text"
arFormFieldsArray(1, iTextFormCount) = objFormField.Result
arFormFieldsArray(2, iTextFormCount) = objFormField.Name
' Select the form field and replace it with placeholder text.
objFormField.Select()
gApplicationWord.Selection.TypeText("")
iTextFormCount = iTextFormCount + 1
Case Word.WdFieldType.wdFieldFormCheckBox
arFormFieldsArray(0, iTextFormCount) = "Checkbox"
arFormFieldsArray(1, iTextFormCount) = CType(objFormField.CheckBox.Value, String)
arFormFieldsArray(2, iTextFormCount) = objFormField.Name
' Select the form field and replace it with placeholder text.
'objFormField.Select()
'gApplicationWord.Selection.TypeText("")
iTextFormCount = iTextFormCount + 1
Case Else
End Select
Next objFormField
' Redim array to hold the exact number of text form fields
ReDim Preserve arFormFieldsArray(2, iTextFormCount - 1)
FormFeldsReplaceFieldsWithParameters = arFormFieldsArray
Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException
Finally
If gbDEBUG_WORD = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then
Call clsError.Handle("FormFeldsReplaceFieldsWithParameters", msCLASSNAME, _
"replace all the form fields with equivalent parameters.", _
mobjCOMException, mobjException)
End If
End Try
End Function
FormFeldsReplaceParametersWithFields
public static void FormFeldsReplaceParametersWithFields(string[,] arFormFieldsArray)
{
try
{
if (clsError.ErrorFlag() == true)
return;
Word.FormField objFormField;
System.Int32 ifieldcount;
gApplicationWord.Selection.HomeKey(Unit: Word.WdUnits.wdStory); // Go to top of document.
gApplicationWord.Selection.Find.ClearFormatting();
{
var withBlock = gApplicationWord.Selection.Find;
withBlock.Forward = true;
withBlock.Wrap = Word.WdFindWrap.wdFindContinue;
for (ifieldcount = 0; ifieldcount <= arFormFieldsArray.GetUpperBound(1); ifieldcount++)
{
while (withBlock.Execute(FindText: "") == true)
{
// Replace the placeholder with the form field.
objFormField = gApplicationWord.Selection.FormFields.Add(Range: gApplicationWord.Selection.Range, Type: Word.WdFieldType.wdFieldFormTextInput);
// Restore form field contents and bookmark name.
objFormField.Result = arFormFieldsArray[1, ifieldcount];
objFormField.Name = arFormFieldsArray[2, ifieldcount];
}
gApplicationWord.Selection.HomeKey(Unit: Word.WdUnits.wdStory); // Go to top of document for next find.
}
}
}
catch (Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
if (gbDEBUG_WORD == true | ((!mobjCOMException == null) | (!mobjException == null)))
clsError.Handle("FormFeldsReplaceParametersWithFields", msCLASSNAME, "replace all the parameters with their original form fields.", mobjCOMException, mobjException);
}
}
Public Shared Sub FormFeldsReplaceParametersWithFields(ByVal arFormFieldsArray(,) As String)
Try
If clsError.ErrorFlag() = True Then Exit Sub
Dim objFormField As Word.FormField
Dim ifieldcount As System.Int32
gApplicationWord.Selection.HomeKey(Unit:=Word.WdUnits.wdStory) 'Go to top of document.
gApplicationWord.Selection.Find.ClearFormatting()
With gApplicationWord.Selection.Find
.Forward = True
.Wrap = Word.WdFindWrap.wdFindContinue
For ifieldcount = 0 To arFormFieldsArray.GetUpperBound(1)
Do While .Execute(FindText:="") = True
' Replace the placeholder with the form field.
objFormField = gApplicationWord.Selection.FormFields.Add(Range:=gApplicationWord.Selection.Range, _
Type:=Word.WdFieldType.wdFieldFormTextInput)
' Restore form field contents and bookmark name.
objFormField.Result = arFormFieldsArray(1, ifieldcount)
objFormField.Name = arFormFieldsArray(2, ifieldcount)
Loop
gApplicationWord.Selection.HomeKey(Unit:=Word.WdUnits.wdStory) 'Go to top of document for next find.
'Do While .Execute(FindText:="") = True
' ' Replace the placeholder with the form field.
' objFormField = gApplicationWord.Selection.FormFields.Add(Range:=gApplicationWord.Selection.Range, _
' Type:=Word.WdFieldType.wdFieldFormCheckBox)
' ' Restore form field contents and bookmark name.
' objFormField.CheckBox.Value = CType(arFormFieldsArray(1, ifieldcount), Boolean)
' objFormField.Name = arFormFieldsArray(2, ifieldcount)
'Loop
'gApplicationWord.Selection.HomeKey(Unit:=Word.WdUnits.wdStory) 'Go to top of document for next find.
Next ifieldcount
End With
Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException
Finally
If gbDEBUG_WORD = True Or _
((Not mobjCOMException Is Nothing) Or (Not mobjException Is Nothing)) Then
Call clsError.Handle("FormFeldsReplaceParametersWithFields", msCLASSNAME, _
"replace all the parameters with their original form fields.", _
mobjCOMException, mobjException)
End If
End Try
End Sub
Handle_Get
public System.IntPtr Handle_Get()
{
System.IntPtr objhandle;
Word.Document objActiveDocument;
string swindowname = "";
bool bfilereadonly = false;
try
{
Tracer_Add2("SUBROUTINE", System.Reflection.MethodBase.GetCurrentMethod().Name + " start");
if (My.Settings.ERROR_OCCURRED == true)
return;
if ((gApplicationWord.Documents.Count > 0))
{
objActiveDocument = Document_GetActive();
swindowname += objActiveDocument.Name;
if ((objActiveDocument.ReadOnly == true))
swindowname += " (Read-Only)";
swindowname += " - " + gApplicationWord.Caption;
objhandle = clsWin32.FindWindow("OpusApp", swindowname);
}
else
{
swindowname += gApplicationWord.Caption;
objhandle = clsWin32.FindWindow("OpusApp", swindowname);
}
return objhandle;
}
catch (Exception ex)
{
modMessages.Exception(System.Reflection.MethodBase.GetCurrentMethod(), null/* TODO Change to default(_) if this is not a reference type */, ex);
}
}
Public Function Handle_Get() As System.IntPtr
Dim objhandle As System.IntPtr
Dim objActiveDocument As Word.Document
Dim swindowname As String = ""
Dim bfilereadonly As Boolean = False
Try
Call Tracer_Add2("SUBROUTINE", System.Reflection.MethodBase.GetCurrentMethod.Name & " start")
If My.Settings.ERROR_OCCURRED = True Then Exit Function
If (gApplicationWord.Documents.Count > 0) Then
objActiveDocument = Document_GetActive()
swindowname &= objActiveDocument.Name
If (objActiveDocument.ReadOnly = True) Then
swindowname &= " (Read-Only)"
End If
swindowname &= " - " & gApplicationWord.Caption
objhandle = clsWin32.FindWindow("OpusApp", swindowname)
Else
swindowname &= gApplicationWord.Caption
objhandle = clsWin32.FindWindow("OpusApp", swindowname)
End If
Return objhandle
Catch ex As System.Exception
Call modMessages.Exception(System.Reflection.MethodBase.GetCurrentMethod, Nothing, ex)
End Try
End Function
InsertBreak
public void Dialogs_InsertBreak()
{
Word.Document objDocument;
try
{
Tracer_Add2("SUBROUTINE", System.Reflection.MethodBase.GetCurrentMethod().Name + " start");
if (My.Settings.ERROR_OCCURRED == true)
return;
objDocument = Document_GetActive();
if (modWordObjectModel.Selection_IsProtected(objDocument) == false)
gApplicationWord.Dialogs(Word.WdWordDialog.wdDialogInsertBreak).Show();
else
modMessages.Breaks_UnableToInsertDocumentProtected();
}
catch (Exception ex)
{
modMessages.Exception(System.Reflection.MethodBase.GetCurrentMethod(), null/* TODO Change to default(_) if this is not a reference type */, ex);
}
}
Public Sub Dialogs_InsertBreak()
Dim objDocument As Word.Document
Try
Call Tracer_Add2("SUBROUTINE", System.Reflection.MethodBase.GetCurrentMethod.Name & " start")
If My.Settings.ERROR_OCCURRED = True Then Exit Sub
objDocument = Document_GetActive()
If modWordObjectModel.Selection_IsProtected(objDocument) = False Then
gApplicationWord.Dialogs(Word.WdWordDialog.wdDialogInsertBreak).Show()
Else
Call modMessages.Breaks_UnableToInsertDocumentProtected()
End If
Catch ex As System.Exception
Call modMessages.Exception(System.Reflection.MethodBase.GetCurrentMethod, Nothing, ex)
End Try
End Sub
New
public SurroundingClass(string sSolutionName, string sDialogPrefix, string sOfficeSolution, Word.Application objWord, string sVersion, clsCmdBar objCmdBar)
{
try
{
gApplicationWord = objWord;
gsSOLUTION_NAME_WORD = sSolutionName;
gsDIALOG_PREFIX_WORD = sDialogPrefix;
gErrorWord = new clsError(gsSOLUTION_NAME_WORD, gsDIALOG_PREFIX_WORD, sOfficeSolution, objWord, sVersion);
gCmdBarWord = objCmdBar;
gbDEBUG_WORD = clsError.DebugFlag("Debug Word");
}
catch (Runtime.InteropServices.COMException objCOMException)
{
mobjCOMException = objCOMException;
}
catch (Exception objException)
{
mobjException = objException;
}
finally
{
if (gbDEBUG_WORD == true | ((IsNothing(mobjCOMException) == false | IsNothing(mobjException) == false)))
clsError.Handle("New", "clsWord", "initialise the 'clsWord' object.", mobjCOMException, mobjException);
}
}
Public Sub New(ByVal sSolutionName As String, _
ByVal sDialogPrefix As String, _
ByVal sOfficeSolution As String, _
ByVal objWord As Word.Application, _
ByVal sVersion As String, _
ByVal objCmdBar As clsCmdBar)
Try
gApplicationWord = objWord
gsSOLUTION_NAME_WORD = sSolutionName
gsDIALOG_PREFIX_WORD = sDialogPrefix
gErrorWord = New clsError(gsSOLUTION_NAME_WORD, gsDIALOG_PREFIX_WORD, _
sOfficeSolution, objWord, sVersion)
gCmdBarWord = objCmdBar
gbDEBUG_WORD = clsError.DebugFlag("Debug Word")
Catch objCOMException As System.Runtime.InteropServices.COMException
mobjCOMException = objCOMException
Catch objException As Exception
mobjException = objException
Finally
If gbDEBUG_WORD = True Or _
((IsNothing(mobjCOMException) = False Or IsNothing(mobjException) = False)) Then
Call clsError.Handle("New", "clsWord", _
"initialise the 'clsWord' object.", _
mobjCOMException, mobjException)
End If
End Try
End Sub
NewDocument
public void AppEvents_NewDocument(Word.Document Doc)
{
if (mbFireEvents == true)
AppEventsNewDocument_Event?.Invoke(Doc);
}
Public Sub AppEvents_NewDocument(ByVal Doc As Word.Document) _
Handles AppEvents2.NewDocument
If mbFireEvents = True Then
RaiseEvent AppEventsNewDocument_Event(Doc)
End If
End Sub
PasteSpecial
public bool Dialogs_PasteSpecial()
{
try
{
gApplicationWord.Dialogs(Word.WdWordDialog.wdDialogEditPasteSpecial).Show();
return true;
}
catch (Exception ex)
{
return false;
}
}
Public Function Dialogs_PasteSpecial() As Boolean
Try
gApplicationWord.Dialogs(Word.WdWordDialog.wdDialogEditPasteSpecial).Show()
Return True
Catch ex As Exception
Return False
End Try
End Function
Quit
public void AppEvents_Quit()
{
if (mbFireEvents == true)
AppEventsQuit_Event?.Invoke();
}
Public Sub AppEvents_Quit() Handles AppEvents2.Quit
If mbFireEvents = True Then
RaiseEvent AppEventsQuit_Event()
End If
End Sub
SaveFileDialog
public string Dialogs_SaveFileDialog()
{
string FileName = string.Empty;
System.Windows.Forms.SaveFileDialog objSaveFileDialog = new System.Windows.Forms.SaveFileDialog();
try
{
Tracer_Add2("SUBROUTINE", System.Reflection.MethodBase.GetCurrentMethod().Name + " start");
if (My.Settings.ERROR_OCCURRED == true)
{
return ""; return;
}
objSaveFileDialog.Filter = "Word Document (*.doc)|*.doc";
}
// Note: SFD owner is set to the Word Application so it is displayed on the same monitor
// If Sfd.ShowDialog(Win32Window) = System.Windows.Forms.DialogResult.OK Then
// FileName = Sfd.FileName
// End If
catch (Exception ex)
{
modMessages.Exception(System.Reflection.MethodBase.GetCurrentMethod(), null/* TODO Change to default(_) if this is not a reference type */, ex);
}
return FileName;
}
Public Function Dialogs_SaveFileDialog() As String
Dim FileName As String = String.Empty
Dim objSaveFileDialog As New System.Windows.Forms.SaveFileDialog
Try
Call Tracer_Add2("SUBROUTINE", System.Reflection.MethodBase.GetCurrentMethod.Name & " start")
If My.Settings.ERROR_OCCURRED = True Then Return "" : Exit Function
objSaveFileDialog.Filter = "Word Document (*.doc)|*.doc"
' Note: SFD owner is set to the Word Application so it is displayed on the same monitor
'If Sfd.ShowDialog(Win32Window) = System.Windows.Forms.DialogResult.OK Then
' FileName = Sfd.FileName
'End If
Catch ex As System.Exception
Call modMessages.Exception(System.Reflection.MethodBase.GetCurrentMethod, Nothing, ex)
End Try
Return FileName
End Function
Startup
public void AppEvents_Startup()
{
if (mbFireEvents == true)
AppEventsStartup_Event?.Invoke();
}
Public Sub AppEvents_Startup() Handles AppEvents.Startup
If mbFireEvents = True Then
RaiseEvent AppEventsStartup_Event()
End If
End Sub
WindowActivate
public void AppEvents_WindowActivate(Word.Document Doc, Word.Window Wn)
{
if (mbFireEvents == true)
AppEventsWindowActivate_Event?.Invoke(Doc, Wn);
}
Public Sub AppEvents_WindowActivate(ByVal Doc As Word.Document, _
ByVal Wn As Word.Window) _
Handles AppEvents.WindowActivate
If mbFireEvents = True Then
RaiseEvent AppEventsWindowActivate_Event(Doc, Wn)
End If
End Sub
WindowBeforeDoubleClick
public void AppEvents_WindowBeforeDoubleClick(Word.Selection Sel, ref bool Cancel)
{
if (mbFireEvents == true)
AppEventsWindowBeforeDoubleClick_Event?.Invoke(Sel, Cancel);
}
Public Sub AppEvents_WindowBeforeDoubleClick(ByVal Sel As Word.Selection, _
ByRef Cancel As Boolean) _
Handles AppEvents.WindowBeforeDoubleClick
If mbFireEvents = True Then
RaiseEvent AppEventsWindowBeforeDoubleClick_Event(Sel, Cancel)
End If
End Sub
WindowBeforeRightClick
public void AppEvents_WindowBeforeRightClick(Word.Selection Sel, ref bool Cancel)
{
if (mbFireEvents == true)
AppEventsWindowBeforeRightClick_Event?.Invoke(Sel, Cancel);
}
Public Sub AppEvents_WindowBeforeRightClick(ByVal Sel As Word.Selection, _
ByRef Cancel As Boolean) _
Handles AppEvents.WindowBeforeRightClick
If mbFireEvents = True Then
RaiseEvent AppEventsWindowBeforeRightClick_Event(Sel, Cancel)
End If
End Sub
WindowDeactivate
public void AppEvents_WindowDeactivate(Word.Document Doc, Word.Window Wn)
{
if (mbFireEvents == true)
AppEventsWindowDeactivate_Event?.Invoke(Doc, Wn);
}
Public Sub AppEvents_WindowDeactivate(ByVal Doc As Word.Document, _
ByVal Wn As Word.Window) _
Handles AppEvents.WindowDeactivate
If mbFireEvents = True Then
RaiseEvent AppEventsWindowDeactivate_Event(Doc, Wn)
End If
End Sub
WindowSelectionChange
public void AppEvents_WindowSelectionChange(Word.Selection Sel)
{
if (mbFireEvents == true)
AppEventsWindowSelectionChange_Event?.Invoke(Sel);
}
Public Sub AppEvents_WindowSelectionChange(ByVal Sel As Word.Selection) _
Handles AppEvents.WindowSelectionChange
If mbFireEvents = True Then
RaiseEvent AppEventsWindowSelectionChange_Event(Sel)
End If
End Sub
WindowSize
public void AppEvents_WindowSize(Word.Document Doc, Word.Window Wn)
{
if (mbFireEvents == true)
AppEventsWindowSize_Event?.Invoke(Doc, Wn);
}
Public Sub AppEvents_WindowSize(ByVal Doc As Word.Document, _
ByVal Wn As Word.Window) _
Handles AppEvents.WindowSize
If mbFireEvents = True Then
RaiseEvent AppEventsWindowSize_Event(Doc, Wn)
End If
End Sub
© 2026 Better Solutions Limited. All Rights Reserved. © 2026 Better Solutions Limited Top