VBA Command in VSTO

Add-in Express™ Support Service
That's what is more important than anything else

VBA Command in VSTO
FilePrintDefault, FilePrint, FilePrintPreview, PreviewClose in VSTO 
Lance Huang




Posts: 1
Joined: 2010-11-24
dear all,


the following codes are my Word VBA for watermark generating and put in Normal->ThisDocument object layer, how to make the same in VSTO?


Dim F_ViewMode As Integer
Dim F_FileName As String


Private Property Let LastViewMode(ByVal mode As Integer)
'codes for Let LastViewMode
End Property

Private Property Get LastViewMode() As Integer
'codes for Get LastViewMode
End Property


Private Property Get GetTheFileName() As String
	GetTheFileName = Application.ActiveDocument.Name
End Property

Sub FilePrintPreview()

	Dim IsWatermarkExists As Boolean
	Dim ShapeCount As Integer

	With ActiveDocument

		Select Case .ActiveWindow.View

			Case wdPrintView '整頁模式 = 3
				If InStr(GetTheFileName, "#.") > 0 Then Call DrawWatermark
				.ActiveWindow.View = wdPrintPreview
				LastViewMode = wdPrintView

		End Select

	End With

End Sub

Sub ClosePreview()

	With ActiveDocument

		Select Case .ActiveWindow.View

			Case wdPrintView '整頁模式 = 3
				If InStr(GetTheFileName, "#.") > 0 Then Call RemoveWatermark
				.ActiveWindow.View = LastViewMode

		End Select

	End With

End Sub

Sub FilePrint()

	With ActiveDocument

		Select Case .ActiveWindow.View

			Case wdPrintView '整頁模式 = 3
				If InStr(GetTheFileName, "#.") > 0 Then Call DrawWatermark
				Dialogs(wdDialogFilePrint).Show
				If InStr(GetTheFileName, "#.") > 0 Then Call RemoveWatermark
				LastViewMode = wdPrintView
				.ActiveWindow.View = LastViewMode


		End Select

	End With
  
End Sub


Sub FilePrintDefault()

	With ActiveDocument

		Select Case .ActiveWindow.View

			Case wdPrintView '整頁模式 = 3
				If InStr(GetTheFileName, "#.") > 0 Then Call DrawWatermark
				.PrintOut
				If InStr(GetTheFileName, "#.") > 0 Then Call RemoveWatermark
				LastViewMode = wdPrintView
				.ActiveWindow.View = LastViewMode

		End Select

	End With

End Sub

Sub DrawWatermark()
'codes for drawing watermark
End Sub

Sub RemoveWatermark()
'codes for removing watermark
End Sub
Posted 24 Nov, 2010 04:42:55 Top
Eugene Astafiev


Add-in Express team


Posts: 8540
Joined: 2007-07-25
Hi Lance,

What version and build number of Add-in Express do you use?
.NET, Extended MAPI, Windows Phone & RT
Posted 24 Nov, 2010 04:58:53 Top