mr relaxo Posted March 11, 2004 Posted March 11, 2004 hi everyone, im trying to create what seems like a pretty straightfoward little app. I basically want the user to be able to select text from listboxes etc from a form and then insert the text at the desired location in a word 2000 document. im using docvariables in the document and i have the following code Public Class Xdocument Shared wordapp As Word.ApplicationClass Shared worddoc As Word.Document Shared wordrange As Word.Range Shared wordbk As Word.Bookmark Shared wordpara As Word.Paragraph Shared fld As Word.Field Shared dv As Word.Variable Shared Function addsometext(ByVal text As String) As Boolean Try wordapp = New Word.ApplicationClass wordapp.Documents.Open("e:\vb\testdoc.doc") 'wordrange = wordapp.ActiveDocument.Range For Each fld In wordapp.ActiveDocument.Fields If fld.Type = Word.WdFieldType.wdFieldDocVariable Then 'if variables name is "something" then '"insert some text here" End If Next i can find the docvariables ok, what i cant figure out is how to access the docvariables properties via the field object. is some sort of cast required or what? I may be totally headed in the wrong direction here so please feel free to point me in the right one. Thanks, Kris. Quote You can not get ye flask.
donnacha Posted February 14, 2005 Posted February 14, 2005 You have probably solved it by now, but if not, maybe this will help as this sample updates the docuent property "Full_Name". Dim mobjWord As Word.Application mobjWord = CreateObject("Word.Application") With mobjWord.ActiveDocument 'Update the custom properties. With .CustomDocumentProperties Try .Item("Full_Name").Value = "Fred Flintstone" Quote Hamlet
Recommended Posts