Link Excel as a mail merge datasource

C

callevib

Hej
I am trying to open a Word document and link an Excel data file to the Word
document as a mail merge data source. I am working with a VBScript in an aspx
page in Visual Studie 2005 and use Office 2003. My Sub looks like:
Sub Button3_onclick
Dim oWord
dim oDoc

flag = true
on Error resume next
set oWord = GetObject(, "Word.Application")
oWord.activate
if Err.number <> 0 then
set oWord = CreateObject("Word.Application")
set oDoc = oWord.documents.add
oWord.visible = true
flag = false
end if
with oWord.oDoc.MailMerge
..MainDocumentType = wdFormLetters
..OpenDataSource Name = "C:\data.xls", _
Connection = "Hele regnearket", _
SQLStatement = "", _
SubType = wdMergeSubTypeOther
end with

set oDoc = nothing
set oWord = nothing
end Sub

Word opens fine but no data is linke to the document.
What am I doing wrong? or is it not posible to do thet?

Callevib
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top