Jacob Help
807607Nov 6 2006 — edited Nov 10 2006Hi ,
I have to do mail merge using jacob and generate the word document.
The below peice of code is working properly for english language .
The problem comes when , we the merge data that contains other than english characters(Korean). The merged document contains gribbled characters instead of Korean characters. When i try to merge the template and the datasource manually , it is asking for the encoding type. If i merge the template by selecting the encoding type to Koren , it is generating the document correctly. Can any one tell me how to set the encoding type , while merging the document.
ComThread.InitMTA();
final ActiveXComponent wordApp = new ActiveXComponent("Word.Application");
Object document = null;
try {
final Object wordDocuments = wordApp.getProperty("Documents").toDispatch();
// Open a file already exits
document = Dispatch.call(wordDocuments, "Open", wordFileName).toDispatch();
final Object mailMerge = Dispatch.get(document, "MailMerge").toDispatch();
Dispatch.call(mailMerge, "OpenDataSource", new Variant(dataSource));
Dispatch.put(mailMerge, "Destination", new Variant(destination));
Dispatch.put(mailMerge, "MailAsAttachment", new Variant(false));
Dispatch.put(mailMerge, "MailAddressFieldName", new Variant(""));
Dispatch.put(mailMerge, "MailSubject", new Variant(""));
Dispatch.put(mailMerge, "SuppressBlankLines", new Variant(false));
Dispatch.call(mailMerge, "Execute", new Variant(true));
Dispatch.call(Dispatch.call(wordApp,"WordBasic").getDispatch(),"FileSaveAs",targetFileName);
Dispatch.call(document, "Close", new Variant(Boolean.FALSE));
wordApp.invoke("Quit", new Variant[]{});
document = null;
}
regards ,
jill,
srinuvir@yahoo.com