Thanks Dmitry.
Would JavaScript make any difference?
Thanks Dmitry.
Would JavaScript make any difference?
I’m not sure how you would access Aspose.Words from JavaScript… it is widely used in dynamic HTML pages but honestly I have not heard that it can be leveraged as a COM client language. Please let me know the way if you’ve succeeded.
Thanks.
Below code still produces the “Type Mismatch” error, but maybe I’m just doing something wrong.
<%@ language="javascript" %>
<html xmlns="http://www.w3.org/1999/xhtml">
http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Testing Aspose CCW</title>
</head>
<body>
<%
var BR="<br>"
Response.Write("HELLO WORLD" + BR)
var objWord = Server.CreateObject("Aspose.Words.ComHelper")
var LicenseFile = "C:\\Program Files\\Aspose\\Aspose.Words\\License\\Aspose.Words.lic"
var License = Server.CreateObject("Aspose.Words.License")License.SetLicense(LicenseFile)
var doc = objWord.Open("C:\\test\\UploadDocs\\TestMergeFields.doc")
MergeFields = new Array(doc.MailMerge.GetFieldNames)
for (var i = 0; i < MergeFields.length; i++){ Response.Write(MergeFields[i] + BR)}
%>
</body>
</html>
Oh I forgot it is available in ASP pages… Anyway, I’m not an expert in JavaScript, sorry. Obviously we should implement a better interoperability in the .NET part, at least because the research took that long (and with no luck so far).
Hi Dimtry,
I followed the VBScript example on Aspose.com and successfully called “document.MailMerge.ExecuteADO” through the ComHelper Class, however I’m not able to replace single MergeFields with “document.MailMerge.Execute”.
Could this be related to the “GetFieldNames” issue?
Yes, that is probably related to type problem. You can use the following workaround to substitute single merge fields with data:
builder.MoveToMergeField(“FieldName”)
builder.Write(“Some Data”)
This code effectively substitutes single merge field with data.
Thanks Vladimir.
This would help if only I could first capture the MergeFields using GetFieldNames.
Oh, I see. Yes, that looks like a big problem for now. The issue is logged to our defect base and we will try to provide some workaround for this in our next version.
Thanks for your support.
Do you know, or can I check, the status of the logged issue?
I will post a notification in this thread once the hotfix will be available.
Hi Vladimir,
I appreciate your support in this matter, and look forward to using the enhanced ComHelper class to enable finding and replacing single mergefields inside Word documents.
My supervisor is wanting to know the estamated time of completion. Do you have anything, time-wise, I can tell him?
Ok, attached is a workaround for you. It contains small .NET DLL with a wrapper for GetFieldNames() method.
You need to put this DLL in your ASP application dir. Then, register it, running “regasm AsposeComWrapper.dll /codebase” command in command line prompt. You may requre setting proper regasm path to be able to do that.
The simple ASP application showing how to use the wrapper is also included in the attachment.
Please try this up and let me know if it worked for you.
Thank you very much.
On all attempts to register AsposeComWrapper.dll the following error from RegSvr32 occurs:
“AsposeComWrapper.dll was loaded, but the DllRegisterServer entry point was not found. This file can not be registered.”
What’s with that?
You should use RegAsm for registering. When you install the .NET Framework version 1.1, RegAsm.exe is placed in the following default directory:
[Windows]\Microsoft.NET\Framework\v1.1.4322
Du. I’m an idiot. Now I noticed you already told me that in the previous email. Sorry.
It regitered fine. I’ll be testing it shortly.
Thanks again.
See also my blog post dedicated to your problem:
https://docs.aspose.com/words/net/supported-platforms/#com
OK. I successfully registered AsposeComWrapper.dll, and while running your test.asp I received:
ASP Error Information:
Page: /DocSystem/Wrapper/test.asp
File: /DocSystem/Wrapper/test.asp [13]
Source:
Category:
Description:
Number: 0x80070002 (-2147024894)
Looks like the error is at the following line:
Set methods = CreateObject(“AsposeComWrapper.Methods”)
Make sure that AsposeComWrapper.dll is present in the same dir as test.asp. Don’t forget to use /codebase key when registering the dll. ‘/codebase’ key gives a warning when trying to register assembly which was not strong signed. I have not seen any problems due to it but still I am sending you strongly signed version.
And one more thing that I have found today. You need to set ‘read’ and ‘read and execution’ permission for IUSR_[ACCOUNTNAME] account for the file AsposeComWrapper.dll, because ASP uses this account to run. Otherwise, you can encounter 0x800A0046 error when creating the AsposeComWrapper.Methods object.
Hope this will help,
I ran “regasm.exe AsposeComWrapper.dll /codebase” and got the following warning:
RegAsm warning: Registering an unsigned assembly with /codebase can cause your assembly to interfere with other applications that may be installed on the same computer. The /codebase switch is intended to be used only with signed assemblies. Please give your assembly a strong name and re-register it.
… however at the conclusion RegAsm.exe said, “Types registered successfully”.
And when I executed test.asp I got a few lines furture. This time I got as far as:
***
For Each element in methods.GetFieldNames(doc)
Response.Write(element + BR)
Next
***
… and then the following error:
***
ASP Error Information:
Page: /DocSystem/Wrapper/test.asp
File: /DocSystem/Wrapper/test.asp [19]
Source:
Category: AsposeComWrapper
Description: Could not load file or assembly ‘Aspose.Words, Version=4.2.3.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’ or one of its dependencies. The system cannot find the file specified.
Number: 0x80070002 (-2147024894)
***
Please note that I have attached storngly named wrapper to my previous post.
Concerning your current problem, make sure you have Aspose.Words 4.2.3 properly setup, and, just to be sure, copy Aspose.Words.dll to your application folder.