Consulting

Results 1 to 9 of 9

Thread: Need urgent help with updating VBA on a MS Word template

  1. #1
    VBAX Newbie
    Joined
    Aug 2022
    Posts
    5
    Location

    Need urgent help with updating VBA on a MS Word template

    need to add a variable which will include a quantity number which will need to calculate the cost and make 5 year budget breakdowns. If someone could please reach out and I'll share more.

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    You provide no details for anyone to work with. In any event, this sort of thing is better suited to Excel than to Word.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    VBAX Newbie
    Joined
    Aug 2022
    Posts
    5
    Location
    Paul, this is MS Word template I created a few years ago and works great in Word. I am not looking into changing it into Excel. Let me make some minor updates then I'll share it with you so you better understand what I'm talking about.
    Thank you for reaching out.

  4. #4
    VBAX Newbie
    Joined
    Aug 2022
    Posts
    5
    Location
    When the info has been loaded to the Word doc, you will see at the top of page 3 "Qty - 1". Right now there is no variable linked to that, nor a field on the form to enter Qty. That is what I need to change. However, I need help with the variable that will do all the calculations for the number of PCs ordered. Is this doable? I was unable to upload the .dot format, but would be happy to do so via email.
    Attached Files Attached Files

  5. #5
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Your document uses Word formfield checkboxes, which means there is/was some VBA code in the template to drive the calculations. Moreover, the document (and template) uses multiple DOCVARIABLE fields that point to Document Variables that would likewise require VBA code to populate. As you've uploaded a docx document, any VBA code that is/was in your template has been deleted from the uploaded document. To upload the dot template, simply zip it and upload the zip archive.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  6. #6
    VBAX Newbie
    Joined
    Aug 2022
    Posts
    5
    Location
    Uploading the zip file.
    Attached Files Attached Files
    Last edited by macropod; 12-05-2022 at 01:36 AM.

  7. #7
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    The code in your template requires giving trusted access to Visual Basic itself. Due to the security risk, I'm not about to do that. You shouldn't, either. The offending line is:
    Me.Caption = ThisDocument.VBProject.Description & " - Step " & mpgSteps.Value + 1
    Regardless, your userform makes no provision for the user to input the number of devices, etc. of a given configuration. Hence the Qty can never be more than 1, so it's a fixed value in the document.

    Due to the hard-coding of item values and device configurations in your userform, your code would also be difficult for anyone else to maintain. You should consider having your code reference a separate text file, Word document, or Excel workbook, and reading the item values and device configurations from there. That way, end-users can simply change the item values and device configurations in the reference file.

    Simply making provision for the user the input the number of devices looks unlikely to be sufficient unless you can ensure all of the ordered devices will have the same configuration; otherwise, you'll need to specify how many Adobe, Project, etc. licenses are required - and, presumably, ensure users can't order more licenses than devices. All this would require a significant coding effort.
    Last edited by macropod; 12-05-2022 at 01:38 AM.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

  8. #8
    VBAX Newbie
    Joined
    Aug 2022
    Posts
    5
    Location
    The thought is of updating the userform by adding a field to input the number of devices, etc. I could do that, it's the hard-coding that I need help with; however, I see what you mean in your last paragraph.

    I have never done any coding that would reference a sperate text file, etc as you recommend. I wouldn't know where to start. Would that change the the whole template and how long will that take?

  9. #9
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Quote Originally Posted by emiranda View Post
    I have never done any coding that would reference a sperate text file, etc as you recommend. I wouldn't know where to start. Would that change the the whole template and how long will that take?
    As I said:
    Quote Originally Posted by macropod View Post
    All this would require a significant coding effort.
    Not only would your template itself need some redesign, so too - especially - would the userform and the code behind it. Since there seems to be a business case for this, your firm should consider engaging a professional coder to do the job.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

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