Results 1 to 3 of 3

Thread: Trouble updating field value with VBA

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2017
    Posts
    2

    Exclamation Trouble updating field value with VBA

    I have created a .docm file that contains a docvariable field called "previousBL". However, in my VBA code, when I try to run ActiveDocument.FormFields("previousBL").Select, I get an error that says "The requested member of the collection does not exist." I have tried using ActiveDocument.Fields, but then I get a "Type mismatch" error. I am calling this function from a DXL script, but even if I try to run it on my own, I get the same issue. I'm hoping that someone can help me out as this function is adding the contents of an HTML file to the end of a pre-configured .docm file then trying to edit this field.


    Chris

  2. #2
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,393

    Re: Trouble updating field value with VBA

    Post the code you are using, or upload a sample workbook.

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Trouble updating field value with VBA

    the error is pretty clear there is no formfield with that name or the field can only be addressed by index
    post a sample of the document and someone will attempt to provide the correct method to access the field
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

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