JasonEnsor
Programmer
Hi Guys,
I am pretty new to VSTO and VB (Although I have done VBA), I am trying to automate inserting custom document properties in to a word document that is generated from excel. I can update built in properties but the custom properties throws an error if I remove the If Statement, if I leave the If statement in the property isn't created.
I am using Visual Studio 2010 and Office 2010
Any Help would be appreciated
J.
I am pretty new to VSTO and VB (Although I have done VBA), I am trying to automate inserting custom document properties in to a word document that is generated from excel. I can update built in properties but the custom properties throws an error if I remove the If Statement, if I leave the If statement in the property isn't created.
I am using Visual Studio 2010 and Office 2010
Code:
Imports Microsoft.Office.Interop
Public Class ThisAddIn
Dim oWord As Microsoft.Office.Interop.Word.Application
Dim oDoc As Microsoft.Office.Interop.Word.Document
' Dim oCustomProps As Microsoft.Office.Interop.Word.CustomProperties
Private Sub ThisAddIn_Startup() Handles Me.Startup
oWord = CreateObject("Word.Application")
oWord.Visible = True
oDoc = oWord.Documents.Add
Dim _BuiltInProperties As Object = oDoc.BuiltInDocumentProperties
Dim oCustomProps As Object = oDoc.CustomDocumentProperties
If oCustomProps Is Nothing Then
oCustomProps.Add("Custom", "Whoop")
End If
If Not _BuiltInProperties Is Nothing Then
_BuiltInProperties("Title").Value = "Testing"
End If
End Sub
Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown
End Sub
End Class
Any Help would be appreciated
J.