Information générale
Catégorie:
COM/DCOM et OLE Automation
Titre:
Data Source Name Not Found and No Default Driver
I have a Mail Merge routine in my VFP 6 SP3 app that 1) when the document is new it associates the data source, launches Word, performs the mail merge 2) when the document is not new it lauches Word and performs the mail merge. This works most of the time. But there are times when I get an error message "Data Source Name is not found and no default driver specified". When I click on the Details button I get "ODBD Error:[Microsoft][ODBC Driver manager] Data source name not found and no default driver specified. Sql State: IM002, Return Code: SQL_ERROR. It seems that I get this error maybe when I copy the Word documents (that already have the data source associated) from one client site to another. Not all clients have the same MDAC or the same configuration. Why does the data source get lost?
MY CODE
goWordApp = createobject("Word.Application")
word_directory = AddBs(JustPath(ctemplate_name))
goWordApp.ChangeFileOpenDirectory (word_directory)
if file(ctemplate_name)
goWordApp.Visible = .T.
goWordApp.documents.open(ctemplate_name)
gowordapp.Application.WindowState = 1
gowordapp.activewindow.windowstate = 3 &&maximized
if creccount != 0
gowordapp.activedocument.mailmerge.destination = 0
goWordApp.ActiveDocument.MailMerge.Execute
endif
else
goWordApp.Visible = .T.
gowordapp.Documents.Add
gowordapp.Application.WindowState = 1
gowordapp.activewindow.windowstate = 1 &&maximized
goWordapp.ActiveDocument.MailMerge.MainDocumentType = 0
goWordapp.ActiveDocument.MailMerge.OpenDataSource(cdatasource)
goWordapp.Activedocument.SaveAs(ctemplate_name)
endif
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement