Results 1 to 3 of 3

Thread: Can i use VB to query data in excel and export to word?

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2017
    Posts
    1

    Can i use VB to query data in excel and export to word?

    Its been a while since ive done anything VB related so im very very rusty

    Is there any way to get VB to query a dataset in excel and export the results and original table to a Word template saved on sharepoint then save the new template as a new file?

    Will be a simple is todays value greater or less than the previous days then export in the form of a red amber or green arrown with some text in the arrows.

  2. #2
    Fanatic Member
    Join Date
    Nov 2016
    Location
    Slovenia
    Posts
    575

    Re: Can i use VB to query data in excel and export to word?

    Is there any way to get VB to query a dataset in excel
    This part, sure.

    and export the results and original table to a Word template saved on sharepoint then save the new template as a new file?
    This part is however confusing - do you need your data in Excel and also Word document, or just a Word document ? ....Anyway, It can be done, but that will take you some time and effort, depends on how your template is designed. For more clearer answers ask a reasonable question, some code won't harm too.

  3. #3
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,532

    Re: Can i use VB to query data in excel and export to word?

    a Word template saved on sharepoint
    That's the trickiest part ... dealing with SharePoint... compared to that, the rest should be a breeze.

    Getting data out of Excel... easy, you can open the file using ADO ... just use the correct settings in the connectionstring.

    Putting the data into the word document (once you can get it out of SP) shoiuld be a simple loop through the Word objects, find the fields you want to stuff, and putting it in there.

    Then of course you SaveAs (doin't save, or it'll overwrite the template) the file and ... what ever you need to do next.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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