[Solved] VBA: Word / Excel

  • Anyone know the syntax for getting excel to change the value of a specific field in an existing word document?


    This used to work
    wordDoc.Fields(3).Text = ActiveWorkbook.Sheets("Data").Cells(5, 4).Value
    But . . . I've lost the document it was linked to and so I think my fault maybe in how the field was inserted in the word document.


    Two questions really but I'll accept an answer for either please.


    John:spin:

  • Hi John,


    Word is not my usual working environment, but try this. It should list the contents of all fields in the document.
    The last bit should change the contents of field 3. Assumsing that your doc has 3 fields.



    Cheers
    Andy

    [h4]Cheers
    Andy
    [/h4]

  • Andy,


    Your code didn't work but gave me more usefull error messages. Doh smeg feck (sound of head ditting desk) sloblock.


    Had not got the MS Word object library loaded !!!


    Your code works, my code works, but in a few moments, my work pc won't as it'll be in the car park.


    Enough of this frivolity, Andy, one big fat thanks.


    John

Participate now!

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