• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

MS Word Macro to pull in SQL data

George

Member
Hi all,

First of all, I know this isn't actually an Excel question, but I figured that this was still the best place to come for help, but as far as I can tell the VBA is broadly similar in word, but this is the first time I've looked at it so it might be drastically different, if so apologies for wasting your time :).

Basically what I want to do is have a macro that runs on document open (so far so easy) which will take data from a SQL table and load it into a specific cell in a table within the word document.

Well aware that this is an unreasonably complex problem to do something relatively simple, but ours is not to question why etc.

Thanks,

George.
 
Thanks Luke, I think that's the right general process.
Going back towards both our comfort zones (excel-ish) - is there any reason you can think of that excel would be able to handle an odc file, but word wouldn't? I'm on Office 2013 in case that helps.

Thanks again :)

George.

[EDIT: it looks like word doesn't put the schema name in when it generates the odc file, which causes an error when it tries to load it, but excel is for some reason less stupid than word and works it out - I guess the fix is going to be to manually write the SQL rather than use the wizard, will feedback if that doesn't work, but for now it seems the problem is more or less solved, even if I can't actually make it work].
 
Back
Top