Hello DolphinMann,
The text below is all from a colleague of mine (Oleh) - but he does not have a registration here in the forums so I am posting on his behalf:
++++++++++++
I tried to convert Microsoft Office documents (DOC, XLS, PPT) with Editor's SDK under Windows Service - and it worked fine for me in Office 2016 - all files are successfully converted.
The HRESULT 0x82191044 error which you received, is equivalent to DISP_E_EXCEPTION error HRESULT, that is sometimes returned by MS Office when an error on their side occurs. So, I suspect that there is something not quite right with your Office installation.
There are cases when Microsoft Office applications may prevent the Editor from correct file processing. It may be due to some modal windows that it may display on startup (e.g. "Some plug-in was not loaded", "MS Office is not activated") - as far as these windows are modal - it does not allow to use Office Application converting office files on THEIR side. So, what I would recommend you to do is:
1) Check whether your Office is activated (not activated office displays modal windows)
2) Manually launch Word, Excel and check whether they work correct and whether they display any modal windows on startup OR on opening the files you do your tests on.
3) Try reinstall MS office (who knows, maybe it will help),
4) Try the same thing on different machine/MS Office installation if possible.
5) Also, you may send a brief project sample that reproduces the problem on your side, along with test files you encounter that error on - and I will try to reproduce the problem on my local machine.
@
What specifically do I need to enable or allow to convert Office files? I know from a previous thread Microsoft Office had to be installed, but is there a specific component, registry setting, or feature I must allow?
Actually you only need Microsoft Office 2007 or later. (activated preferred)
2007's version should have XPS Add-In installed and also there are some registry settings that may disable Office's ability to convert files to XPS and PDF (as you've seen earlier in this post).
But since you are using MS Office 2016 and you are able to convert files when you run your program as *.exe file - everything is OK with what I've just mentioned.
+++++++++++++++
And he also gave me this code which he says does work properly for him:
Code: Select all
public partial class Service1 : ServiceBase
{
public Service1()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
PDFXEditTestFunc();
}
public void PDFXEditTestFunc()
{
PDFXEdit.PXV_Inst Inst = new PDFXEdit.PXV_Inst();
Inst.Init(null, "", null, null, null, (int)PDFXEdit.PXV_AppTypeFlags.PXV_AppType_SDK);
//MS EXCEL
string sRequiredConv = "conv.imp.office.xls";
string sSrcFile = "SampleFile.xls";
//MS POWERPOINT
//string sRequiredConv = "conv.imp.office.ppt";
//string sSrcFile = "SampleFile.pptx";
//MS WORD
//string sRequiredConv = "conv.imp.office.doc";
//string sSrcFile = "SampleFile.doc";
PDFXEdit.IPXV_ImportConverter iConv = null;
for (uint i = 0; i < Inst.ImportConvertersCount; i++)
{
if (Inst.ImportConverter[i].ID.Equals(sRequiredConv))
{
iConv = Inst.ImportConverter[i];
break;
}
}
if (iConv != null) //found converter
{
PDFXEdit.IAFS_Inst fsInst = (PDFXEdit.IAFS_Inst)Inst.GetExtension("AFS");
string curDir = AppDomain.CurrentDomain.BaseDirectory + "\\Files\\";
PDFXEdit.IAFS_Name sSrcFilename = fsInst.DefaultFileSys.StringToName(curDir + sSrcFile);
int openFileFlags = (int)(PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_Read | PDFXEdit.AFS_OpenFileFlags.AFS_OpenFile_ShareRead);
PDFXEdit.IAFS_File srcFile = fsInst.DefaultFileSys.OpenFile(sSrcFilename, openFileFlags);
PDFXEdit.ICab cab = Inst.GetFormatConverterParams(true, sRequiredConv);
PDFXEdit.IPXC_Document resDoc = null;
try
{
resDoc = iConv.Convert((PDFXEdit.PXV_Inst)Inst, srcFile, 0, cab);
}
catch
{
}
if (resDoc != null)
{
resDoc.WriteToFile(curDir + sSrcFile + ".pdf");
resDoc.Close();
}
}
Inst.Shutdown();
}
protected override void OnStop()
{
}
}
I hope the above will help you resolve the problem at your end, and if it does not please send us the sample Oleh asks for in 5) above.
Regards,
Stefan