Hello all
I would like to have Word stuck into my application so that a user can run a mail merge from it, using an excel file as the data source. The idea is to have everything done from my application...
Here is the code I have. On my form there is an OLE control and a button X.
-----------------------------------------------------------Private Sub X_Click()
OLE1.CreateEmbed "c:\blank.doc" 'blank document
OLE1.object.mailMerge.MainDocumentType = wdFormLetters
OLE1.object.mailMerge.OpenDataSource "c:\test.xls", ReadOnly:=True, linktosource:=False
OLE1.object.CommandBars(11).Enabled = True
OLE1.DoVerb vbOLEUIActivate
OLE1.DoVerb vbOLEShow
OLE1.DoVerb vbOLEInPlaceActivate
End Sub
-----------------------------------------------------------
Why doesn't this work? I know it successfully opens the data source, because it pops up a dialog box that i recognize from excel, asking me if i want to put the entire spreadsheet range in. When it's done opening the data source, the command bar is still "greyed out" and it will not let me get to mail merge via the Tools menu.
I hope someone can shed some light on this...
Thanks
Aaron.
I would like to have Word stuck into my application so that a user can run a mail merge from it, using an excel file as the data source. The idea is to have everything done from my application...
Here is the code I have. On my form there is an OLE control and a button X.
-----------------------------------------------------------Private Sub X_Click()
OLE1.CreateEmbed "c:\blank.doc" 'blank document
OLE1.object.mailMerge.MainDocumentType = wdFormLetters
OLE1.object.mailMerge.OpenDataSource "c:\test.xls", ReadOnly:=True, linktosource:=False
OLE1.object.CommandBars(11).Enabled = True
OLE1.DoVerb vbOLEUIActivate
OLE1.DoVerb vbOLEShow
OLE1.DoVerb vbOLEInPlaceActivate
End Sub
-----------------------------------------------------------
Why doesn't this work? I know it successfully opens the data source, because it pops up a dialog box that i recognize from excel, asking me if i want to put the entire spreadsheet range in. When it's done opening the data source, the command bar is still "greyed out" and it will not let me get to mail merge via the Tools menu.
I hope someone can shed some light on this...
Thanks
Aaron.