Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OLE container is frustrating!

Status
Not open for further replies.

KowCiller

Programmer
Aug 5, 2002
10
0
0
US
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.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top