Save visio file as DWG or DXFin C#

520 views Asked by At

Am using Microsoft.Office.Interop.Visio to create a visio file. It's working as expected. Now the new requirement is to save the file as DWG and DXF.

I saw Page.Export Method to export the visio file to different file type. But using export method it's not generating the DWG and DXF other than that everything is generating.

Microsoft.Office.Interop.Visio.Document doc = VisioApplication.Documents.OpenEx( sFileToWrite, stick );
int iCount = doc.Pages.Count;
for( int i = 0; i < iCount - 1; i++ )
                     {
    Microsoft.Office.Interop.Visio.Page page = doc.Pages.get_ItemFromID( i + 1 );
    page.Export("E:\\thejus" + i + ".dwg" ); //not working
    page.Export("E:\\thejus" + i + ".bmp" ); //working
 }

Please let me know if someone knows the reason

2

There are 2 answers

0
thejustv On BEST ANSWER

everything is correct. My visio license was expired because of that the file was not creating.

1
user9403507 On
Visio.Document Document=App.Documents.OpenEx("D:\\Temp\\trees_top_with_shadow.dwg", Flags);
int iCount = Document.Pages.Count;
for (int i = 0; i < iCount; i++)
{
    Microsoft.Office.Interop.Visio.Page page = Document.Pages.get_ItemFromID(i);                    
    page.Export("D:\\temp\\thejus" + i + ".svg"); //working
    page.Export("D:\\temp\\thejus" + i + ".bmp"); //working
}