Image Placeholder

Started by thalantyrdsl, July 12, 2017, 10:13:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

wapperdude

#15
Updated.  Simple change.  Will now fill in missing spots.

Cheers.
wapperdude

PS.  Other options, delete one or more shapes, then do a copy paste of existing shape.  It will fill in open spot.  Other:  use insert picture from file, or just draw a shape.  Hmmm.  Jus t occurred to me, macro always fires.  That will be a problem.  May have to hard code the page, then inhibit if not correct page.
Visio 2019 Pro

wapperdude

OK.  One more modification.  Code modified to place pictures on page named "Pics".  If any other page is active, then macro will not do anything.

Wapperdude
Visio 2019 Pro

thalantyrdsl

Quote from: wapperdude on July 14, 2017, 04:44:59 AMOK.  One more modification.  Code modified to place pictures on page named "Pics".  If any other page is active, then macro will not do anything.

There looks to be a bug when deleting an image it's not resetting the 'max' number of images allowed.
Eg: I delete 8, then add 1 and it says max number reached, though it places that last image in the centre of the page anyway.

The placement seems to be working great.

wapperdude

The macro was all talk, no action!   ;D

Now it backs up it words!   ;)
Visio 2019 Pro

thalantyrdsl

Quote from: wapperdude on July 14, 2017, 05:09:09 AM
The macro was all talk, no action!   ;D
Now it backs up it words!   ;)

Awesome. That's stopping the picture from being pasted as per the popup message, but the counter doesn't seem to be reducing as images are removed.

thalantyrdsl

Also, I assume that Visio treats 'images' as shapes? Is there a way to differentiate between shapes and images?
The reason I ask is that I will need to place other information over the top of the images, such as a 'number reference' and also a 'text box' with a description.

If I paste on x8 images and then try to add a text box it looks to be counting them as shapes.

thalantyrdsl

Quote from: metuemre on July 13, 2017, 10:28:37 AMSolution
Thank you Metuemre. When I try to run the script that you wrote I get the attached error regarding a 64-bit operating system. I'm unsure how to approach this.[/quote]

Hi Metuemre. I was wondering if you knew what the problem could be here? I'd love to get the double-click insert image working if possible. Thank you.

wapperdude

#22
The "counter" isn't tracking number of shapes on the page.  Rather, it looks at shape ID's.  This was a quick and dirty solution and relies on known Visio behavior. 

So, 1st shape placed, Visio considers as sheet.1, 2nd is sheet.2 up thru sheet.8.  Let's say, 6 shapes have been placed, and you decide 4th shape should be deleted.  The next shape placed will be a new sheet.4, not sheet.7.  New sheet.4 replaces previously deleted sheet.4.  The next shape will be sheet.7.  So, had sheets 2, 4, 5 been deleted, they would be replaced sequentially before more are added.  Thus, the code leverages the behavior of Visio to remain relatively simple in structure.  Perhaps not very elegant or robust, but it gets the job done. 

Update:
Ah.  The task definition has changed.  Unlike Metuemre's (and Yacine's) solution(s), this approach just grabs whatever comes its way.  It's a strength and weakness that the other approaches avoid.  Visio treats all shapes as sheets.xyz. Not sure if there's an easy way to distinguish a picture from other shape types.

Wapperdude.
Visio 2019 Pro

metuemre

Hi thalantyrdsl, is your Visio 32bit or 64bit? My template works on 32bit Visio only

thalantyrdsl

Quote from: metuemre on July 14, 2017, 06:15:56 AM
Hi thalantyrdsl, is your Visio 32bit or 64bit? My template works on 32bit Visio only

I run Windows 64-bit so I assume Visio is 64-bit.
Is there a way to make the template work on both 32-bit & 64-bit, so it's not limited based on versions?

Thank you.

metuemre

Quote from: wapperdude on July 13, 2017, 03:22:31 PM
Most impressive!  Simple indeed! :D  Yes simple to use, but the development and code was hardly simple.  You pulled this together in amazingly short order.

Nice job metuemre.  Works very well.

wapperdude

Thanks wapperdude but most of the credit goes to AndyW for CComDlg class  :D

http://visguy.com/vgforum/index.php?topic=738.0

thalantyrdsl

Quote from: wapperdude on July 14, 2017, 06:13:32 AM
The "counter" isn't tracking number of shapes on the page.  Rather, it looks at shape ID's.  This was a quick and dirty solution and relies on known Visio behavior. 

So, 1st shape placed, Visio considers as sheet.1, 2nd is sheet.2 up thru sheet.8.  Let's say, 6 shapes have been placed, and you decide 4th shape should be deleted.  The next shape placed will be a new sheet.4, not sheet.7.  New sheet.4 replaces previously deleted sheet.4.  The next shape will be sheet.7.  So, had sheets 2, 4, 5 been deleted, they would be replaced sequentially before more are added.  Thus, the code leverages the behavior of Visio to remain relatively simple in structure.  Perhaps not very elegant or robust, but it gets the job done. 

Wapperdude.

Thanks Wapper. Sorry if I'm getting confused.
These are the steps I've taken to get the error:

- Open your attachment
- Delete shapes 1,2,3,4,6,7,8, leaving #5
- Copy & Paste #5
- It pastes into location 6
- Paste it another two times, pastes into location 7 & 8
- Paste it a fourth time, comes up with the error about too many shapes

metuemre

Quote from: thalantyrdsl on July 14, 2017, 06:21:00 AM
Quote from: metuemre on July 14, 2017, 06:15:56 AM
Hi thalantyrdsl, is your Visio 32bit or 64bit? My template works on 32bit Visio only

I run Windows 64-bit so I assume Visio is 64-bit.
Is there a way to make the template work on both 32-bit & 64-bit, so it's not limited based on versions?

Thank you.

It is possible to install 32bit or 64bit Visio on 64bit operating system. Assuming that Visio is 64bit, please try the version attached

thalantyrdsl

Quote from: metuemre on July 14, 2017, 06:31:23 AM
It is possible to install 32bit or 64bit Visio on 64bit operating system. Assuming that Visio is 64bit, please try the version attached

That didn't seem to fix the issue for me. Same error as previously attached.

It may be something that I'm doing. Can I please ask why there are two attachments?
Do I need to add something in before the script will work?

metuemre

Please try this one.

.vsd file is for those who have Visio 2010 or older versions