Word Merges

For years and years now, I’ve been merging Foxpro data in Microsoft Word. It doesn’t always work smoothly and I’ve spent probably more time than I should walking clients through ODBC driver installs, but its always work and, hey, if it ain’t broke – don’t fix it.

Word 2016 broke it. Stupid Word 2016.

Merging Foxpro to Word 2016 gets an “Could not find installable ISAM” error. Crap. I decided it was probably time I stopped trying to merge with Foxpro data (OK, first I tried to Google a solution but couldn’t find one, THEN I decided not to use Fox data anymore).

I decided I’d just convert the Fox data to Excel in my program and then merge that. Works great, except that Word 2016 pops up a “Select Table” dialogue box and asks you to select a worksheet. Stupid Work 2016. DisplayAlerts = .f. does not stop that behavior. Stupid, stupid Work 2016.

A bit of googling turned up that I should pass a select statement to bypass the dialogue box. It looks like this then:

this.o.ActiveDocument.MailMerge.OpenDataSource(lFile,,,,,,,,,,,,”SELECT * FROM ‘Sheet1$'”)

Still not working. Stupid Word 2016. Study the google result a little more carefully, tweak the statement to this:

this.o.ActiveDocument.MailMerge.OpenDataSource(lFile,,,,,,,,,,,,”SELECT * FROM `Sheet1$`”)

Voila! Works. You can totally see the difference right? The Sheet1$ has to have a backwards quote mark around it, not a regular quote mark. WTH is a backwards quote mark? Stupid Word 2016. But it works.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s