Re: Programmatically insert Visio pictures
- From: Mark Mayle <MarkMayle@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 10 Dec 2007 23:04:02 -0800
Did some further work on this. The second parameter on sendkeys needs to be
False not True. This parameter tells the function whether to wait until
processing is complete before moving on to the next statement. It is the
"wait" parameter. We do NOT want to wait, as immediately after we send the
keys we call the insert function which pops up the file dialog box and gets
populated with the keys we sent. If wait is True, it takes the keys and
shoves them into the shape object, then moves on and inserts the picture.
This works perfectly in VBA in a Visio macro.
Now for the problem. My program is a VB.net application with no user
interface (it will be kicked off via a separate application). It uses Visio
as an automation server; when I try to call the send method from my app I
get an error message stating: SendKeys cannot run inside this application
because the application is not handling Windows messages. Either change the
application to handle messages, or use the SendKeys.SendWait method.
I may go back to my previous method of just reproducing the insert picture
function manually. This works but I need to get all of the shape rows and
cells that describe the placement of the picture correct.
"David Parker" wrote:
Not pretty, but a loop with something like the following would work:.
Dim shp As Visio.Shape
Dim adn As Visio.Addon
Set adn = Visio.Addons("OrgC11")
'Loop thru your shapes
Set shp = Visio.ActivePage.Shapes("Assistant")
Visio.ActiveWindow.DeselectAll
Visio.ActiveWindow.Select shp, Visio.VisSelectArgs.visSelect
SendKeys "C:\Users\davidp\Pictures\anypicture.jpg{ENTER}", True
adn.Run "/cmd=InsertPicture"
'end loop
"Mark Mayle" wrote in message news:200712615184m_elyam@xxxxxxxxxxxx
I also need to programmatically insert pictures into my Visio (2007) org
chart shapes (created with the wizard). Any idea how to do this? I cannot
seem to find any information on how and where these are kept or how they
can be accessed via the Visio object model. The reply above did not help
me achieve this. Maybe I am missing something?
EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com
- Follow-Ups:
- Re: Programmatically insert Visio pictures
- From: John Goldsmith
- Re: Programmatically insert Visio pictures
- From: David Parker
- Re: Programmatically insert Visio pictures
- References:
- Visio Organization Chart Pictures
- From: Steve Fibelkorn
- Programmatically insert Visio pictures
- From: Mark Mayle
- Re: Programmatically insert Visio pictures
- From: David Parker
- Visio Organization Chart Pictures
- Prev by Date: Re: Visio 2007 print issue - Printing shape text containing "\"
- Next by Date: Re: Programmatically insert Visio pictures
- Previous by thread: Re: Programmatically insert Visio pictures
- Next by thread: Re: Programmatically insert Visio pictures
- Index(es):
Relevant Pages
|