muhasem.blogg.se

How to mail merge labels from excel to word 2016
How to mail merge labels from excel to word 2016





how to mail merge labels from excel to word 2016

odc format, not the current one, and does not interpret its contents correctly - as you say, it does not recognise a query in there, and wrongly uses the meta name as the source of the table name. I think you have pretty much got it right.ĪFAICR Word only recognises the older. (It's probably easier to do that in Excel, though). But you could probably still use MS Query to help you construct your SQL. MS Query only works for ODBC queries, and they do not always work correctly when you actually issue the query using ODBC from Word, because of a Word problem to do with Unicodeįields in SQL Server. Query option now, and I am not sure it works with the latest versions of Word). That may still be possible (it is a bit harder to find the MS in the COnnection:= parameter in OpenDataSource.Īs background, until Word 2000, by default you would use MS Query to create your SQL query, and MS Query does have facilities that can help you build your query (a bit like the ones in MS Access). you may need to quote all your table names. You get a maximum of either 255 or around 511 characters in the SQL statement, and Word tends to impose some syntax requirements that Transact-SQL does not, so e.g. SQLStatement1:="put the second part in here"

how to mail merge labels from excel to word 2016

SQLStatement:="put your SQL statement in here, and if it is long.", _ Let's say it is called "c:\a\myodc.odc" Then in VBA you can use something likeĪctiveDocument.OpenDataSource Name:="c:\a\myodc.odc, _ needed to connect to the correct server and database. odc (Office Data Connection file) which has the info. You either have to be able to create a View in SQL Server that performs the query you need, then connect to that, or you have to be able to create the correct query manually (or perhaps using some other query tool that can help you), then use VBA to connectįor example, if you have been through the connection process once (connecting to a single table) then you will have a. Word and the current data source dialog do not really give you any help with that.







How to mail merge labels from excel to word 2016