- #Directory mail merge in word for labels how to#
- #Directory mail merge in word for labels code#
- #Directory mail merge in word for labels password#
Once your mailing addresses are set up in an Excel spreadsheet (see the previous video to learn how), it's a snap to get Word to create mailing labels from them. When Automation is complete, Word appears with a new document that contains the mailing labels that resulted from the mail merge.This year, you can avoid that awful permanent-marker smell and get all your holiday card and package labeling done in a few quick steps. Start Internet Explorer and browse to (where servername is the name of your Web server).Ĭlick the button on the Web page to automate Word and perform the mail merge. ' Save the recordset in the Response object.Ĭhange the sServer variable in Default.asp to point to your Web server, and change the sSQLServer variable in Getdata.asp to point to your SQL Server. Set oRS = oConn.Execute(“SELECT * FROM AUTHORS”) Set oConn = Server.CreateObject("ADODB.Connection") "User ID= Password= Initial Catalog=pubs Data Source=" & sSQLServer StrConn = "Provider=SQLOLEDB.1 Persist Security Info=False " & _
#Directory mail merge in word for labels password#
' the username and password of an account that has permissions on the database. Save the file to the WordMailMerge virtual directory.
#Directory mail merge in word for labels code#
Use Notepad to create a file called Getdata.asp that contains the code given below. ' Uncomment these lines to save the merged document locally. Destination = 0 ' 0 = wdSendToNewDocument "MyLabelLayout",, 4 ' 4 = wdPrinterManualFeed MainDocumentType = 1 ' 1 = wdMailingLabels Set oApp = CreateObject("Word.Application") ' Get a range object and insert the text into the document. STemp = Mid(sHead, 1, Len(sHead) - 1) & vbCrLf & sTemp ' Append the field names to the front of the string. STemp = oRS.GetString(2, -1, vbTab) ' 2 = adClipString
![directory mail merge in word for labels directory mail merge in word for labels](https://i.ytimg.com/vi/bKdIeUA6Iqo/maxresdefault.jpg)
ORS.Open " & sServer & "/WordMailMerge/Getdata.asp" Set oRS = CreateObject("ADODB.Recordset") ĭim sServer,oDoc,oRS,sTemp,sHead,oRange,oField Use Notepad to create a file called Default.asp that contains the code given below. On your Web server, create a virtual directory that is called WordMailMerge. However, similar code may be used to perform a mail merge with any database to which you can make an ADO connection. See the "References" section of this article for links to additional resources on using ADO with XML.įor illustration purposes, the following sample uses the sample Pubs database in Microsoft SQL Server.
![directory mail merge in word for labels directory mail merge in word for labels](http://www.trainingtech.net/wp-content/uploads/2012/10/mailmerge2.png)
In turn, clients can use ADO to read the XML recordset and manipulate the data as needed.
![directory mail merge in word for labels directory mail merge in word for labels](https://support.content.office.net/en-us/media/a3637dd7-6057-4df4-b8ad-0d8be5769a73.png)
![directory mail merge in word for labels directory mail merge in word for labels](https://excelnotes.com/wp-content/uploads/2020/02/word-Create-Labels-large-1024x582.jpg)
Using ASP on a Web server, you can build an ADO recordset from a database and return the data as XML to your clients. More InformationĪctiveX Data Objects (ADO) 2.5 and later allows recordset data to be persisted in XML format. Client-side script converts this XML data to a delimited text file that is local to the client and then automates Word to perform a mail merge by using the local text file as the mail merge data source. The sample illustrates Active Server Pages (ASP) code that streams an XML recordset from a Web server to a client. Word does not have a direct method for using XML data as the data source for a mail merge.
#Directory mail merge in word for labels how to#
This article demonstrates how to automate Microsoft Word from client-side script to perform a mail merge for labels.