K
Kim Helmer
I have made a macro that works fine in Word, but when I paste it into a
VB.net project some of the code appears as 'not declared'. The code that
shows not declared is activedocument, wdCollapseEnd and wdCollapseEnd.
What reference/import am I missing.
All help appreciated.
----
imports Word
imports Microsoft.Office.Core
---
Sub kims()
Dim wordDocument As Word.Document
Dim tableRange As Word.Range
Dim pictureRange As Word.Range
Dim pictureTable As Word.Table
Dim feltet As Word.Field
Set wordDocument = ActiveDocument
wordDocument.Paragraphs.Add
Set tableRange = wordDocument.Paragraphs.Last.Range
Set pictureTable = wordDocument.Tables.Add(tableRange, 1, 1)
Set pictureRange = pictureTable.Cell(1, 1).Range
pictureTable.Columns.Item(1).Width = 120
pictureTable.Rows.Item(1).Height = 120
Dim picture As String
picture = "c:\\test.jpg"
Set pictureRange = ActiveDocument.Content
pictureRange.Collapse Direction:=wdCollapseEnd
pictureRange.Fields.Add pictureRange, Type:=wdFieldEmpty,
Text:="INCLUDEPICTURE """ & picture & """" _
, PreserveFormatting:=False
End Sub
VB.net project some of the code appears as 'not declared'. The code that
shows not declared is activedocument, wdCollapseEnd and wdCollapseEnd.
What reference/import am I missing.
All help appreciated.
----
imports Word
imports Microsoft.Office.Core
---
Sub kims()
Dim wordDocument As Word.Document
Dim tableRange As Word.Range
Dim pictureRange As Word.Range
Dim pictureTable As Word.Table
Dim feltet As Word.Field
Set wordDocument = ActiveDocument
wordDocument.Paragraphs.Add
Set tableRange = wordDocument.Paragraphs.Last.Range
Set pictureTable = wordDocument.Tables.Add(tableRange, 1, 1)
Set pictureRange = pictureTable.Cell(1, 1).Range
pictureTable.Columns.Item(1).Width = 120
pictureTable.Rows.Item(1).Height = 120
Dim picture As String
picture = "c:\\test.jpg"
Set pictureRange = ActiveDocument.Content
pictureRange.Collapse Direction:=wdCollapseEnd
pictureRange.Fields.Add pictureRange, Type:=wdFieldEmpty,
Text:="INCLUDEPICTURE """ & picture & """" _
, PreserveFormatting:=False
End Sub