Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Word 2002 Mail Merge with HTML file
I am using VB.net (currently, I am able to connect to SQL Server
tables using open data source).. can I use WordObj.MAilMerge.OpenDataSource to connect to my HTML file? |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Word 2002 Mail Merge with HTML file
I think you should be able to unless Word 2002 differs from Word 2003 in
this respect. However, what happens depends on how the data is structured within the HTML file. Assuming WordObj actually references a Word.Document object, have you tried the VB.NET equivalent of WordObj.MailMerge.OpenDataSource _ Name:="the path name of your HTML file" or maybe WordObj.MailMerge.OpenDataSource _ Name:="the path name of your HTML file", _ Subtype:=wdMergeSubtypeOther ? If the HTML file just contains a single table, you should be OK (the data source is treated rather like a Word document containing a table). however, if the HTML file contains something more like a comma-delimited or tab-delimited source, you will probably see a dialog asking what the delimters should be. In this case, the data source is treated more like a ..txt file opened using Word's .txt file converter). Peter Jamieson "c_shah" wrote in message ups.com... I am using VB.net (currently, I am able to connect to SQL Server tables using open data source).. can I use WordObj.MAilMerge.OpenDataSource to connect to my HTML file? |
#3
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Word 2002 Mail Merge with HTML file
Peter it works..only thing is I am getting a select table dialog box..
Dim WordApp As New Word.Application Dim WordDoc As New Word.Document Try WordApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone WordApp.Visible = True 'Make Word Visible WordDoc = WordApp.Documents.Open("C:\MailMerge\Forms \CANCELLATION_LETTER.doc") WordDoc.MailMerge.OpenDataSource(Name:= _ "C:\MailMerge\Forms \CANC_LETTER.html" _ , SubType:=Word.WdMergeSubType.wdMergeSubTypeWord200 0) ' the above line ask select a table, HTML code looks fine to me WordDoc.MailMerge.Destination = Word.WdMailMergeDestination.wdSendToNewDocument ' suppress blank lines when mail merge fields in a mail merge main document are empty 'WordDoc.MailMerge.SuppressBlankLines = True WordApp.ActiveDocument.MailMerge.SuppressBlankLine s = True 'Perform Merge WordDoc.MailMerge.Execute() WordApp.ActiveDocument.SaveAs("C:\MailMerge\Forms\ test.doc") WordApp.ActiveDocument.Close() WordDoc.Close(False) Catch ex As Exception MessageBox.Show(ex.ToString) Finally WordDoc = Nothing WordApp.Quit(False) System.Runtime.InteropServices.Marshal.ReleaseComO bject(WordApp) WordApp = Nothing End Try |
#4
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Word 2002 Mail Merge with HTML file
OK, this is not very familiar ground for me, but...
When the Select table dialog pops up, note the table name (let's say it is 'xyz') Then try: WordDoc.MailMerge.OpenDataSource( _ Name:="C:\MailMerge\Forms\CANC_LETTER.html", _ SQLStatement:="SELECT * FROM `abc`", _ SubType:=Word.WdMergeSubType.wdMergeSubTypeAccess) I leave you to get the syntax right, but you may find that you can use [abc] instead of `abc` This suggests that Word 2002 connects by default using the Jet OLE DB driver and its HTML engine, and that even if there is only one table in the HTML file, you will still be prompted if you do not supply the SQL that selects the table - I think that's different from the way Word 2003 does it, but there may be some other difference I am not aware of. It surprises me that using the wdMergeSubTypeWord2000 option does not work, but there it is. There are some rules about how the OLE DB provider determines the names of tables inside an HTML document - I'll try to dig them out. Peter Jamieson "c_shah" wrote in message ps.com... Peter it works..only thing is I am getting a select table dialog box.. Dim WordApp As New Word.Application Dim WordDoc As New Word.Document Try WordApp.DisplayAlerts = Word.WdAlertLevel.wdAlertsNone WordApp.Visible = True 'Make Word Visible WordDoc = WordApp.Documents.Open("C:\MailMerge\Forms \CANCELLATION_LETTER.doc") WordDoc.MailMerge.OpenDataSource(Name:= _ "C:\MailMerge\Forms \CANC_LETTER.html" _ , SubType:=Word.WdMergeSubType.wdMergeSubTypeWord200 0) ' the above line ask select a table, HTML code looks fine to me WordDoc.MailMerge.Destination = Word.WdMailMergeDestination.wdSendToNewDocument ' suppress blank lines when mail merge fields in a mail merge main document are empty 'WordDoc.MailMerge.SuppressBlankLines = True WordApp.ActiveDocument.MailMerge.SuppressBlankLine s = True 'Perform Merge WordDoc.MailMerge.Execute() WordApp.ActiveDocument.SaveAs("C:\MailMerge\Forms\ test.doc") WordApp.ActiveDocument.Close() WordDoc.Close(False) Catch ex As Exception MessageBox.Show(ex.ToString) Finally WordDoc = Nothing WordApp.Quit(False) System.Runtime.InteropServices.Marshal.ReleaseComO bject(WordApp) WordApp = Nothing End Try |
#5
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Word 2002 Mail Merge with HTML file
Peter, everything is working now....i recorded a macro and used the
connection string recorded by the macro... found somewhere in this newsgroup a post from Cindy M... thank you...... |
#6
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Word 2002 Mail Merge with HTML file
You are right....table name that's what I needed..when I recorded a
macro it had that table name as in sql statement SQLStatement:="SELECT * FROM `Table`" |
#7
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Word 2002 Mail Merge with HTML file
Peter, if you are reading this...
I would appreciate if you could answer my question..is there a limitation on number of merge fields (if you use HTML file as your datasource)? |
#8
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Word 2002 Mail Merge with HTML file
Sorry, I don't know for certain and am not in a position to check right now,
but a. if Word is using its native facility to open HTML files, which it probably is when it reads an HTML table and you aren't using OLE DB, I would guess the limit is the same as the Word table column count maximum - 63 or 64 b. if Word is using the text converter, the limit is likely to be "a large number - perhaps well over 500) c. if Word is using OLE DB, which it is when you specify Word.WdMergeSubType.wdMergeSubTypeAccess, the limit is /likely/ to be either 127 or 255. Peter Jamieson "c_shah" wrote in message oups.com... Peter, if you are reading this... I would appreciate if you could answer my question..is there a limitation on number of merge fields (if you use HTML file as your datasource)? |
#9
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Word 2002 Mail Merge with HTML file
Thanks!
|
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Word 2002 Mail Merge Error via Excel 2002, XP Op System | Mailmerge | |||
Mail Merge HTML Format Word 2002 XP SP3 | Mailmerge | |||
create an email merge in word 2002 using an existing html document | Mailmerge | |||
Using HTML file as data source for Mail Merge | Mailmerge | |||
Automate a mail merge in Word 2002 from a macro in Access 2002 | Mailmerge |