Diagram Preview

Started by Nikolay, September 09, 2010, 06:04:16 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Nikolay

How do I generate a small diagram "preview" (thumbnail) picture programmatically (you can see those in explorer, for example)?
Supposing I have either a Visio file on disk, or a Visio Document object (not sure which one might be a better starting point)

I can see following options:
- Grab thumbnail data from explorer using some shell api (which one?)
- Export drawing to some manageable vector format, then resize (which format? wmf/emf? how to preserve background?)

As a result, I want a fixed-size bitmap (say, 64x64)
Thanks in advance!

Jumpy

Check out
ActiveDocument.PreviewPicture
in the help.

I don't understand everything they say there, but it seems to be sth. with emf file.
Maybe you can make more sense of what is said there.



Nikolay

Thanks! I'll definitely give it a try.

aledlund

I use something like this in my vba code

docCopy.SavePreviewMode = visSavePreviewDraft1st
docCopy.SaveAsEx strCopy, visSaveAsWS
DoEvents
docCopy.Close
DoEvents

al

Nikolay

Thanks al, but doesn't this code save document with preview picture?
I don't actually need to save document with preview picture; I need the document preview picture itself ;)

It seems that Document.PreviewPicture did the trick pretty well, and the only thing left to me were the boring technical details:

IPicture pic = (IPicture)doc.PreviewPicture;
Image img = new Metafile((IntPtr)pic.Handle, true);

JuneTheSecond

Cool!
Your solution is valuable to me, too.
Thank you.
Best Regards,

Junichi Yoda
http://june.minibird.jp/

aledlund

sorry about that! I obviously misunderstood what you were attempting to do  :(
al