Open Microsoft Word and fill form with cell value

  • Hello all,


    I want to copy some cell values into a Word document that has a form to fill in. This is what I have done



    I think that this is kind a Word question, than an Excel one, but I cannot figure why I cannot point to a word "FormField" from Excel. I can write .Selection.TypeText Text:="something" (To an unlocked document of course), or even print with ".PrintOut", but it seems imposible to fill a form! The document is "locked" and it only allow forms to be filled, maybe this could be the problem?


    Any help will be much appreciated!!

  • Re: Open Microsoft Word and fill form with cell value


    You seem to be referencing the Word application object rather than the actual document you are opening.

    Boo!:yikes:

  • Re: Open Microsoft Word and fill form with cell value


    Actually this simple approach doesn't work either.



    In case I were referencing the object, why does the print statment work?

  • Re: Open Microsoft Word and fill form with cell value


    Just to test that all the code is working as spected. If the print works, it should work the


    Code
    wd.FormFields("Nombre").Result = "Whatever!"


    If you try to write up on excel's VBA editor, it should open word and print out the referenced document. Just comment the pintout and the error should point again to the above line.


    Thanks for your help!

  • Re: Open Microsoft Word and fill form with cell value


    Hi,


    I was able to write values to a formfield in a word doc. Is it possible the formfield name is not correct?
    Can you post an example of the word file?

    [h4]Cheers
    Andy
    [/h4]

  • Re: Open Microsoft Word and fill form with cell value


    Quote from norie

    I tried your code with a formfield called Nombre and commenting out the print code.


    It worked.


    I think that my problem is that I'm not including some Office Library. Anyway, using bookmarks on the Word file has worked for me. I have only replaced all the forms stuff with


    Code
    wd.Selection.Goto What:=wdGoToBookmark, Name:=WordFileBoormarkName
    wd.Selection.TypeText Text:="Whatever"


    Thanks so much for your help anyway!!! :thanx: :gift:

  • Re: Open Microsoft Word and fill form with cell value


    Glad you have it working, but like I said I used your original code and it worked fine.


    I had extra references to any libraries.


    In your original post you mentioned that the document was locked, perhaps that is the problem.

    Boo!:yikes:

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!