Can I have a Ghost Control using Reflections.

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,
I've finally getting into .NET and have a question for you all. I'm creating
an app that needs to insert user data into a word doc. One way I thought of
doing this was to save the Word Bookmark names, Control names and db field
names in a XML file. in the app I would like to be able to load those items
into memory and use these items to fill out the word doc without the code
knowing the name of the controls or db fields. Heres an idea of what I'd like
to do:
'Load XML file
While reader.Read()
Select Case (reader.NodeType)
Case XmlNodeType.Element
'Format(reader, "Element")
If (reader.Name = "ControlName") Then
Console.WriteLine(reader.ReadElementString()) 'goes
to console for now. But will save into some structure.
End If
If (reader.Name = "BookMark") Then
Console.WriteLine(reader.ReadElementString())
End If
End Select
End While
'Open the word doc
doc = ThisApplication.Documents.Open(FileName:=VB6.GetPath & "Note.dot")
ThisApplication.Visible = True
ThisApplication.WindowState = Word.WdWindowState.wdWindowStateMaximize
''''The following line is where I need help.
'colItems.ControlName is the Name of the control that was found in the
XML file.
'colItems.BookMark is the name od the Word Bookmark.
doc.FormFields.Item(Word Bookmark).Result = ControlGhost(Word.
ControlName).Text

If I remember correctly, I beleive I read somewhere that with reflection
you could do something like this with the controls. Is this correct? If so,
how is the best way to go about that. Is there any articles that cover this
topic. Thanks for any help that you can provide.
Michael Lee
 
Back
Top