I’m a SQL Goeroe who is implementing automatic mailmerging via SQL Server with Aspose.
Well, talking to the Aspose component is not a problem except for calling the constructor with a filename which is not possible.
I can create a new instance with an new empty document and perform all routines I want.
What I cannot do is open an existing document! I’ve tried using the .Template propterie of the DocumentBuildInProperties property but this just add a template instead of an existing document.
Does anyone know which method (other than the constructor) to call to provide an existing document. Maybe through Node?
Are you using the component inside a COM application? If so, use the Word.Open method to load the document from a file or stream. Otherwise, please describe why you failed to use the constructor to open the document.
Well, I’ve tried to use the Open() method which works. Except that I can either make an object of Aspose.Word.Word OR Aspose.Word.Document. If I create an object of Aspose.Word.Word I can open an existing document. I need members and methods of Aspose.Word.Document to work on my document. Those are not available from my Aspose.Word.Word object. Are you with me?
I have two different objects who cannot interact with each other.
What I need is an Open method in the Aspose.Word.Document object. Is that possible?
I’m not familiar with SQL Server support for COM inside stored procedures, but even from your code sample above it sounds like it should all work fine.
To create a new document from a COM client you need to do this:
Dim doc
Set doc = CreateObject("Aspose.Word.Document")
To open an existing document from a COM client you do this:
Dim word
Set word = CreateObject("Aspose.Word.Word")
Dim doc
Set doc = word.Open("myfile.doc")
In SQL you already retrieve and store pointers to COM objects, for example Document.BuiltInDocumentProperties returns a COM interface to you. You retrieve it using sp_OAGetProperty and store int an OUT variable. I think there must be some other sp_XXX that allows to call a method and the result will be in the last OUT parameter.
This is how it probably looks in SQL Server:
EXEC @hr = sp_OACallMethod `@word`, ‘Open’, "myFile.doc", @document OUT