With Me .Show() I get error "end of statement expected"
When I get to the following code in the sample below: with me .show()
I get the error: end of statement expected
First, using Visual Studio Tools for Office, create a Microsoft Visual Basic Word Document project.
Name the project TaskPaneExample2. In your new project, do the following:
Set a reference to System.Drawing.dll.
Add a Windows Form to the project, and name the file TaskPane2.
vb.
Drop a text box (leave it named TextBox1) and two buttons (named GetValueButton and
SetValueButton) onto the TaskPane2 form.
Add the following code above Public Class TaskPane2:
Imports Word = Microsoft.Office.Interop.Word
Imports System.Windows.Forms
Add the following code to the TaskPane2 - (Declarations) section:
Private wordDocument As TaskPaneExample2.OfficeCodeBehind
Dim screenHeight As Integer
Dim screenWidth As Integer
Dim heightPoints As Single
Dim widthPoints As Single
Dim dpi As Single
Dim document As Word.Document
Change the TaskPane2.New method so that it looks like this:
Public Sub New(ByVal wordDoc As TaskPaneExample2.OfficeCodeBehind)
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
Me.wordDocument = wordDoc
Dim screen As Screen = screen.PrimaryScreen
screenHeight = screen.WorkingArea.Height
screenWidth = screen.WorkingArea.Width
' Show the TaskPane2 form and initially size it to take up
' half the screen.
With Me .Show()
.Height = screenHeight
.Width = screenWidth / 2
.Top = 0
.Left = screenWidth / 2
End With
Dim graphics As System.Drawing.Graphics = Me.CreateGraphics
dpi = graphics.DpiX
heightPoints = screenHeight / dpi * 72
widthPoints = (screenWidth / 2) / dpi * 72
End Sub