• Visio has the ExportAsFixedFormat() method to create PDF and XPS files. When calling from VB everything works but from C# you may receive a COMException
  • Assuming you have PDF and XPS support installed for your version of office, the problem is likely the last parameter: FixedFormatExtClass
  • The MSDN docs imply that a null can be passed: http://msdn.microsoft.com/en-us/library/ms409271.aspx
  • But that is what is causing the problem, pass System.Reflection.Missing.Value instead.

Here are the code samples … with differences highlighted in RED

WHAT DOES NOT WORK

WHAT DOES WORK

var PrintRange = IVisio.VisPrintOutRange.visPrintAll;

int FromPage = 1;

int ToPage = 1;

var ColorAsBlack = false;

var IncludeBackground = true;

var IncludeDocumentProperties = false;

var IncludeStructureTags = true;

var UseISO19005_1 = false;

object FixedFormatExtClass = null;

doc.ExportAsFixedFormat(   IVisio.VisFixedFormatTypes.visFixedFormatPDF,

    Filename,

IVisio.VisDocExIntent.visDocExIntentPrint,

    PrintRange,

    FromPage,

    ToPage,

    ColorAsBlack,

    IncludeBackground,

    IncludeDocumentProperties,

    IncludeStructureTags,

    UseISO19005_1,

    FixedFormatExtClass);

var PrintRange = IVisio.VisPrintOutRange.visPrintAll;

int FromPage = 1;

int ToPage = 1;

var ColorAsBlack = false;

var IncludeBackground = true;

var IncludeDocumentProperties = false;

var IncludeStructureTags = true;

var UseISO19005_1 = false;

var FixedFormatExtClass = System.Reflection.Missing.Value;

doc.ExportAsFixedFormat(

IVisio.VisFixedFormatTypes.visFixedFormatPDF,

    Filename,

   IVisio.VisDocExIntent.visDocExIntentPrint,

    PrintRange,

    FromPage,

    ToPage,

    ColorAsBlack,

    IncludeBackground,

    IncludeDocumentProperties,

    IncludeStructureTags,

    UseISO19005_1,

    FixedFormatExtClass);