maddernc

Howdy All

Not sure if these is the right place for this but, I am doing some research for a proposal to a client.
Can the functionality of the plugin ie save office docs to PDF be done programmatically

Regards

Cain


Re: Visual Studio Tools for Office Save to PDF Office 2007 Plugin

Steve Hansen

Hi Cain,

Yep - you need the plugin of course. Get it at: http://www.microsoft.com/downloads/details.aspx familyid=f1fc413c-6d89-4f15-991b-63b07ba5f2e5&displaylang=en

Here is a link to the documentation for the method you need to use: http://msdn2.microsoft.com/en-us/library/bb238907.aspx

Here is an example for Excel:

public void SaveAsPDF()
{
Excel.Workbook wb;
wb = Application.ActiveWorkbook;
try
{
wb.ExportAsFixedFormat(Microsoft.Office.Interop.Excel.XlFixedFormatType.xlTypePDF,
"c:\test.pdf",
Excel.XlFixedFormatQuality.xlQualityStandard,
true,
false,
missing,
missing,
true,
missing);

}
catch (Exception)
{
// an error is thrown if there isn't anything in the
// workbook to export
}
}

Regards,

Steve






Re: Visual Studio Tools for Office Save to PDF Office 2007 Plugin

maddernc

Howdy Steve

Thanks for that, it answers my question and my next question once i try to do it!!

Thanks heaps

Regards

Cain




Re: Visual Studio Tools for Office Save to PDF Office 2007 Plugin

Gabriela D

I wrote a class library that automates Excel2007: fills an excel file with data from database, runs macros and eventually exports to PDF. The code is called from a COM+ application that runs under ¡°Myself¡± user that is not logged on the computer.

When calling:

ws.ExportAsFixedFormat(paramExportFormat,

paramExportFilePath, paramExportQuality,

paramIncludeDocProps, paramIgnorePrintAreas, paramFromPage,

paramToPage, paramOpenAfterPublish,

missing);

The code returns ¡°Exception from HRESULT: 0x800A03EC¡± error.

If I¡¯m logging via Terminal Services as ¡°MySelf¡±, the code runs fine.

I suspect that there is no (default ) printer installed for tha user until the user loggs on but I don¡¯t know how I can load it.

Is there is any way to work around the problem

Thank you,

Gabriela