Results 1 to 7 of 7

Thread: Populating a word docs test based on a bookmark value using VBA in Access and SQL Ser

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2018
    Posts
    4

    Populating a word docs test based on a bookmark value using VBA in Access and SQL Ser

    Hi.

    We have an application that populates a word documents bookmarks. We have table tbat holds the bookmark values and the VBA Code that adds the resulting values to the word document... Client has requested us to remove Template line of text if the bookmark below it is null. So we have a word template on the users computer that when the users clicks report , the vba code stored in sql server runs and populates the word documents bookmarks. But there words that need to be removed from the template if the bookmark returns nothing..See below

    Template wording to be removed if bookmark is null

    You have the following errors""""

    [bookmark] which may be blank

    The ""You have the folowwing errors" needs to be deleted of the originating template.

    How can I do this usign VBA?

    Thanks very much for your help

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: Populating a word docs test based on a bookmark value using VBA in Access and SQL

    Welcome to the Forums.

    Thread moved from classic vb6 forum to office development/vba forum
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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

    Re: Populating a word docs test based on a bookmark value using VBA in Access and SQL

    can you post the code to populate the bookmarks and also a copy of the template?
    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

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2018
    Posts
    4

    Re: Populating a word docs test based on a bookmark value using VBA in Access and SQL

    Quote Originally Posted by westconn1 View Post
    can you post the code to populate the bookmarks and also a copy of the template?

    Okay thanks!




    The call goes to a sql server table where the rows look like below
    LOBID Template Bookmark Value FormatType VBACode
    somenumber Qu InsuredAddress12 Forms("frmMain").subContacts.Form.cboInsuredStreetAddress1.Column(1) NULL NULL


    The field VBACode has VBA CODE THAT RUNS AND POPULATES THE sorry caps the template with data.

    Sorry I cannot figure outhow to add the bookmark template to this reply.

    Thanks
    Chris
    Last edited by Chris David; Dec 3rd, 2018 at 03:00 PM.

  5. #5

    Thread Starter
    New Member
    Join Date
    Dec 2018
    Posts
    4

    Re: Populating a word docs test based on a bookmark value using VBA in Access and SQL

    I am trying to insert this into a sql table and let the vba code run this but I cannot get this code to work. Can someone assist? This will run from a field in a table in sql server and populate the template if the list is greater than 0

    insertText|IIf(Forms("Form_frmMain_subSubjAndEndor").lstSubjectivitySelected > 0, "This quote is subject to the following", NULL)

  6. #6

    Thread Starter
    New Member
    Join Date
    Dec 2018
    Posts
    4

    Re: Populating a word docs test based on a bookmark value using VBA in Access and SQL

    This is failing.. Can someone assist ?

    insertText|IIf(Forms("Form_frmMain_subSubjAndEndor").lstSubjectivitySelected > 0, "This quote is subject to the following", NULL)
    Last edited by Chris David; Dec 3rd, 2018 at 10:53 AM.

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

    Re: Populating a word docs test based on a bookmark value using VBA in Access and SQL

    Sorry I cannot figure outhow to add the bookmark template to this reply.
    click go advanced, then manage attachments
    post the vba code within code tags

    insertText|IIf(Forms("Form_frmMain_subSubjAndEndor").lstSubjectivitySelected > 0, "This quote is subject to the following", NULL)
    i have no idea what this is supposed to do, which part is failing, you may have to break it into 2 lines using a variable, to test
    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