Visio 2007 Programmatically (C#) Save as Web Page (JPG)

W

Woof

Successfully creating Visio docs on the fly through
Microsoft.Office.Interop.Visio. I can save the newly created doc as a VSD. I
can also see the method to save as a PDF, but I need to save as a JPG.

Trying to use
Microsoft.Office.Interop.Visio.Document.Pages[0].Export("whatever.jpg");
throws an "Invalid container identifier" exception.

Can anyone point me in the right direction???
Many thanks.
 
P

Paul Herber

Successfully creating Visio docs on the fly through
Microsoft.Office.Interop.Visio. I can save the newly created doc as a VSD. I
can also see the method to save as a PDF, but I need to save as a JPG.

Trying to use
Microsoft.Office.Interop.Visio.Document.Pages[0].Export("whatever.jpg");
throws an "Invalid container identifier" exception.

the pages index starts at 1.
 
J

John

Hello Woof,

A few points here:

a) Which 'Document' are you refering to?

b) The Pages collection has an index starting at 1 not 0.

c) The Export method requires a full path to export to (eg "C:\Documents and
Settings\All Users\Desktop\whatever.jpg").

Hope that helps

Best regards

John
 
W

Woof

Paul & John,

Thanks a million. Problem was the page index (I was already using a full
path). I'm so used to 0 page indexing in my code that I didn't even think
this could be the issue, and 'Invalid Container Identifier' was a little too
vague for me.

Thanks guys.

John said:
Hello Woof,

A few points here:

a) Which 'Document' are you refering to?

b) The Pages collection has an index starting at 1 not 0.

c) The Export method requires a full path to export to (eg "C:\Documents and
Settings\All Users\Desktop\whatever.jpg").

Hope that helps

Best regards

John


Woof said:
Successfully creating Visio docs on the fly through
Microsoft.Office.Interop.Visio. I can save the newly created doc as a VSD.
I
can also see the method to save as a PDF, but I need to save as a JPG.

Trying to use
Microsoft.Office.Interop.Visio.Document.Pages[0].Export("whatever.jpg");
throws an "Invalid container identifier" exception.

Can anyone point me in the right direction???
Many thanks.
 
J

JuneTheSecond

I also tryed and got it on Drawing Control on Form1 as

Microsoft.Office.Interop.Visio.Document mydoc;
mydoc = axDrawingControl1.Document;
mydoc.Pages[1].Export("C:/mymytesttest.jpg");

--
JuneTheSecond



Woof said:
Paul & John,

Thanks a million. Problem was the page index (I was already using a full
path). I'm so used to 0 page indexing in my code that I didn't even think
this could be the issue, and 'Invalid Container Identifier' was a little too
vague for me.

Thanks guys.

John said:
Hello Woof,

A few points here:

a) Which 'Document' are you refering to?

b) The Pages collection has an index starting at 1 not 0.

c) The Export method requires a full path to export to (eg "C:\Documents and
Settings\All Users\Desktop\whatever.jpg").

Hope that helps

Best regards

John


Woof said:
Successfully creating Visio docs on the fly through
Microsoft.Office.Interop.Visio. I can save the newly created doc as a VSD.
I
can also see the method to save as a PDF, but I need to save as a JPG.

Trying to use
Microsoft.Office.Interop.Visio.Document.Pages[0].Export("whatever.jpg");
throws an "Invalid container identifier" exception.

Can anyone point me in the right direction???
Many thanks.
 
W

Woof

Try replacing:

mydoc.Pages[1].Export("C:/mymytesttest.jpg");

with

mydoc.Pages[1].Export("C:\\mymytesttest.jpg");

double FORWARD slash = \ escape character


JuneTheSecond said:
I also tryed and got it on Drawing Control on Form1 as

Microsoft.Office.Interop.Visio.Document mydoc;
mydoc = axDrawingControl1.Document;
mydoc.Pages[1].Export("C:/mymytesttest.jpg");

--
JuneTheSecond



Woof said:
Paul & John,

Thanks a million. Problem was the page index (I was already using a full
path). I'm so used to 0 page indexing in my code that I didn't even think
this could be the issue, and 'Invalid Container Identifier' was a little too
vague for me.

Thanks guys.

John said:
Hello Woof,

A few points here:

a) Which 'Document' are you refering to?

b) The Pages collection has an index starting at 1 not 0.

c) The Export method requires a full path to export to (eg "C:\Documents and
Settings\All Users\Desktop\whatever.jpg").

Hope that helps

Best regards

John


Successfully creating Visio docs on the fly through
Microsoft.Office.Interop.Visio. I can save the newly created doc as a VSD.
I
can also see the method to save as a PDF, but I need to save as a JPG.

Trying to use
Microsoft.Office.Interop.Visio.Document.Pages[0].Export("whatever.jpg");
throws an "Invalid container identifier" exception.

Can anyone point me in the right direction???
Many thanks.
 
W

Woof

Sorry, not sure my suggestion above will make any difference in hindsight.

Woof said:
Try replacing:

mydoc.Pages[1].Export("C:/mymytesttest.jpg");

with

mydoc.Pages[1].Export("C:\\mymytesttest.jpg");

double FORWARD slash = \ escape character


JuneTheSecond said:
I also tryed and got it on Drawing Control on Form1 as

Microsoft.Office.Interop.Visio.Document mydoc;
mydoc = axDrawingControl1.Document;
mydoc.Pages[1].Export("C:/mymytesttest.jpg");

--
JuneTheSecond



Woof said:
Paul & John,

Thanks a million. Problem was the page index (I was already using a full
path). I'm so used to 0 page indexing in my code that I didn't even think
this could be the issue, and 'Invalid Container Identifier' was a little too
vague for me.

Thanks guys.

:

Hello Woof,

A few points here:

a) Which 'Document' are you refering to?

b) The Pages collection has an index starting at 1 not 0.

c) The Export method requires a full path to export to (eg "C:\Documents and
Settings\All Users\Desktop\whatever.jpg").

Hope that helps

Best regards

John


Successfully creating Visio docs on the fly through
Microsoft.Office.Interop.Visio. I can save the newly created doc as a VSD.
I
can also see the method to save as a PDF, but I need to save as a JPG.

Trying to use
Microsoft.Office.Interop.Visio.Document.Pages[0].Export("whatever.jpg");
throws an "Invalid container identifier" exception.

Can anyone point me in the right direction???
Many thanks.
 
M

Mos

Hi Woof,
I im trying to convert the vsd file that I create in my visio automation
application to gif file.
when the Export statement "VisApp.ActivePage.Export("My path\filename.gif")"
runs, it runs OK first time, but when I again run the application the, the
gif file previously created is holded by some process and it is not replaced.
can you please help me out of this.
Regards,
Woof said:
Sorry, not sure my suggestion above will make any difference in hindsight.

Woof said:
Try replacing:

mydoc.Pages[1].Export("C:/mymytesttest.jpg");

with

mydoc.Pages[1].Export("C:\\mymytesttest.jpg");

double FORWARD slash = \ escape character


JuneTheSecond said:
I also tryed and got it on Drawing Control on Form1 as

Microsoft.Office.Interop.Visio.Document mydoc;
mydoc = axDrawingControl1.Document;
mydoc.Pages[1].Export("C:/mymytesttest.jpg");

--
JuneTheSecond



:

Paul & John,

Thanks a million. Problem was the page index (I was already using a full
path). I'm so used to 0 page indexing in my code that I didn't even think
this could be the issue, and 'Invalid Container Identifier' was a little too
vague for me.

Thanks guys.

:

Hello Woof,

A few points here:

a) Which 'Document' are you refering to?

b) The Pages collection has an index starting at 1 not 0.

c) The Export method requires a full path to export to (eg "C:\Documents and
Settings\All Users\Desktop\whatever.jpg").

Hope that helps

Best regards

John


Successfully creating Visio docs on the fly through
Microsoft.Office.Interop.Visio. I can save the newly created doc as a VSD.
I
can also see the method to save as a PDF, but I need to save as a JPG.

Trying to use
Microsoft.Office.Interop.Visio.Document.Pages[0].Export("whatever.jpg");
throws an "Invalid container identifier" exception.

Can anyone point me in the right direction???
Many thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top