I am developing a program in visual basic and what I want to do is the following: from a .txt file fill in a word template (.dotx). The text file has a header separated by tabs and below it a series of rows with the data (also separated by tabs).
the code I have is the following
Dim oApp As Word.Application
Dim oDoc As Word.Document
Dim arg()
arg = Environment.GetCommandLineArgs()
Dim destinoDoc As String = "carteles\"
Dim nomFichero As String
nomFichero = arg(1)
Dim cDestino As String = "carteles\" + nomFichero + ".txt"
My.Computer.FileSystem.CopyFile(My.Application.Info.DirectoryPath + "\Plantilla.dotx", My.Application.Info.DirectoryPath + "\" + nomFichero + ".dotx")
Dim sPlantillaWord = "\" + nomFichero + ".dotx"
oApp = CreateObject("Word.Application")
oDoc = oApp.Documents.Add(My.Application.Info.DirectoryPath + "\" + nomFichero + ".dotx")
With (oDoc.MailMerge)
.MainDocumentType = Word.WdMailMergeMainDocType.wdNotAMergeDocument
.OpenDataSource(Name:=My.Application.Info.DirectoryPath + "\" + cDestino)
.Destination = Word.WdMailMergeDestination.wdSendToNewDocument
.Execute()
End With
oDoc.Close(False)
...
When executing it in local it works perfectly for me, but when executing it by ssh it gives me an error that I can not solve.
Unhandled exception: System.Runtime.InteropServices.COMException: Word could not open the data source. in Microsoft.Office.Interop.Word.MailMerge.OpenDataSource (String Name, Object & Format, Object & ConfirmConversions, Object & ReadOnly, Object & LinkToSource, Object & AddToRecentFiles, Object & PasswordDocument, Object & PasswordTemplate, Object & Revert, Object & WritePasswordDocument, Object & WritePasswordTemplate, Object & Connection, Object & SQLStatement, Object & SQLStatement1, Object & OpenExclusive, Object & SubType)
Any ideas?