Author Topic: Diagram Preview  (Read 6496 times)

0 Members and 1 Guest are viewing this topic.

Nikolay

  • Hero Member
  • *****
  • Posts: 1307
    • UnmanagedVisio
Diagram Preview
« on: September 09, 2010, 01:04:16 PM »
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

  • Hero Member
  • *****
  • Posts: 1061
Re: Diagram Preview
« Reply #1 on: September 09, 2010, 01:49:14 PM »
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

  • Hero Member
  • *****
  • Posts: 1307
    • UnmanagedVisio
Re: Diagram Preview
« Reply #2 on: September 09, 2010, 01:55:02 PM »
Thanks! I'll definitely give it a try.

aledlund

  • Hero Member
  • *****
  • Posts: 1412
Re: Diagram Preview
« Reply #3 on: September 09, 2010, 02:51:04 PM »
I use something like this in my vba code

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

al

Nikolay

  • Hero Member
  • *****
  • Posts: 1307
    • UnmanagedVisio
Re: Diagram Preview
« Reply #4 on: September 09, 2010, 10:33:34 PM »
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

  • Hero Member
  • *****
  • Posts: 1027
    • Visio Shapes, Stencils and Sample Drawings
Re: Diagram Preview
« Reply #5 on: September 10, 2010, 01:57:05 AM »
Cool!
Your solution is valuable to me, too.
Thank you.
Best Regards,

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

aledlund

  • Hero Member
  • *****
  • Posts: 1412
Re: Diagram Preview
« Reply #6 on: September 10, 2010, 10:00:22 AM »
sorry about that! I obviously misunderstood what you were attempting to do  :(
al