Results 1 to 12 of 12

Thread: [RESOLVED] Write text to textfield in word

  1. #1

    Thread Starter
    Member
    Join Date
    May 2008
    Posts
    32

    Resolved [RESOLVED] Write text to textfield in word

    I have a .dot file with a textfield (not a part of a form) in the pageheader. I can select the pageheader but don't know how to select the textfiels.
    Also when i have a bookmark in this textfield, i can't use this from te main document.

    Can someone help me with this?


    Dim oWord = New Word.Application
    oWord.Visible = True
    Dim oDoc As New Word.Document
    oDoc = oWord.Documents.Add("C:\Documents and Settings\Andy\Bureaublad\Brief.dot")

    'first lets get to the header of the document
    oDoc.Content.Application.ActiveWindow.ActivePane.View.SeekView = CInt(Word.WdSeekView.wdSeekCurrentPageHeader)

  2. #2
    Hyperactive Member Zeljko's Avatar
    Join Date
    Oct 2006
    Location
    Internet
    Posts
    441

    Re: Write text to textfield in word

    I cant help you but what will I do wenn I try to do similar things in automating word:
    1. start recording a macro in word
    2. do whatever I have to do (in your case I will: eneter with cursor in field, enter text in Field, exit field)
    3. Stop recording macro
    4. See VBA code that Word has created auitomaticaly
    5. Study it, and transform it to VB code
    That VBA code is very similar to VB code that you need

    Hope it helped
    1. If this post helped you, please Rate it = That's You, saying Thanks, to Me ...Left side of this post: [Rate this post]
    2. Mark this Thread Resolved if your question has been answered That's You, saying Thanks, to Group ...Menu on top of your original Post: [Thread Tools]>[Mark Thread Resolved]
    3.
    Check my site: www.er-ef.netCheck my snippets: Get installed .NET versionsRegex extractingJoin hierarchically nested Datatables in one flattened Datatable


  3. #3

    Thread Starter
    Member
    Join Date
    May 2008
    Posts
    32

    Re: Write text to textfield in word

    It's not that easy. When i was recording the macro i couldn't select first my pageheader and second the text shape in that header. I couldn't use my mouse to help me.

    But with a lot of trying in vb.net i allready found the sollution.

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Write text to textfield in word

    Hello,

    If you have found a solution to your problem remember to share with the community.

    Can you post what you did to resolve your problem?

    Gary

  5. #5

    Thread Starter
    Member
    Join Date
    May 2008
    Posts
    32

    Re: Write text to textfield in word

    Yes, no problem.



    Dim objWord As New Word.Application
    Dim objDoc As New Word.Document

    With objWord
    objWord.Visible = False

    objDoc = objWord.Documents.Open(Application.StartupPath & "\template.dot")
    objDoc.Sections(1).Headers(Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage).Shapes.Item(2).TextFram e.TextRange.Select()
    .Selection.Font.Underline = Word.WdUnderline.wdUnderlineNone
    .Selection.Font.Name = "Tahoma"
    .Selection.Font.Size = 8
    .Selection.Font.Color = 6976647
    .Selection.TypeText(Text:="This is a test:" & vbCrLf)
    ............


    I hope this will help other people because it was hard to find on google .

  6. #6
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Write text to textfield in word

    Thanks!!

    Like you say, hopefully this will help people in the future.

    To make things easier, you might want to mark your thread as resolved, and then also use the new tagging feature that is available on the threads, following the upgrade last night. This will help if people are searching for a particular tag. You can find more information about the new features here:

    http://www.vbforums.com/showthread.php?t=561973

    Gary

  7. #7

    Thread Starter
    Member
    Join Date
    May 2008
    Posts
    32

    Re: Write text to textfield in word

    I added 5 tags.
    I don't find where i can select this thread as resolved.

  8. #8
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Write text to textfield in word

    have a look in my signature, there is a link in there explaining how to do that.

    Gary

  9. #9

    Thread Starter
    Member
    Join Date
    May 2008
    Posts
    32

    Resolved Re: Write text to textfield in word

    Doens't work.
    Invalid FAQ Item specified. If you followed a valid link, please notify the administrator.

    But i found it. It's the green V-mark.

  10. #10
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Write text to textfield in word

    Hey,

    I have updated the link in my signature.

    What you have done is not setting the thread as resolved

    Gary

  11. #11

    Thread Starter
    Member
    Join Date
    May 2008
    Posts
    32

    Re: [RESOLVED] Write text to textfield in word

    Was een poging waard .
    Heb het gevonde, bedankt.

  12. #12
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: [RESOLVED] Write text to textfield in word

    No idea what you just said (I am hoping it was good )

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width