Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

You can not get ye flask.
  • 11 months later...
Posted

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"

Hamlet
Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...