Picture Transparency Object in PowerPoint VBA - vba

PowerPoint added native capability for picture transparency (without having to create a shape) in late 2018. See that linked article to see what I mean.
I'm trying to figure out what/if an appropriate VBA object exists for it (there's not much online since it's a fairly new feature). I've tried the traditional FillFormat.Transparency object, as well as a few other analogous attempts. (Basically, have been searching the VBA documentation up and down for an hour or two).
Any thoughts?

Currently, there is no way to set the Picture Transparency directly (without using a Shape Fill). You would notice that the Shape properties are arranged somewhat as it appears on the Picture Tools Pane. For example, the Picture settings are on the last tab (where you have Picture Corrections, Color, Transparency and Crop). These are all accessible with the Shape.PictureFormat object. (The .FillFormat is only applicable when you are filling a shape).
You will notice the .PictureFormat has Properties relating to the aforementioned settings, except for Picture Transparency. The .PictureFormat.TransparencyColor cannot be used to set the degree of transparency.

The PowerPoint VBA object model often lags well behind new features that appear in the user interface, so there's nothing available yet to do what you want.
Just a note, when it appears, transparency will be a property, not an object. The current TransparencyColor and TransparentBackground properties are for the old routine that creates a single picture color that is 100% transparent.

Related

Convert an embedded Excel Picture into an Object

I created a logo in Publisher.
Using TechSmith Snagit, I captured the image and saved as a JPEG.
I fetched the image inside of Excel and placed it in a properly sized cell(s)
I don't want to have a file that has the image (have seen in researching some solutions) -- Nevertheless, everything must be self-contained in my Excel vba Application.
Excel (2013) has a tendency to either erase the image or it creeps when the app is opened on other displays. (And it does this with ActiveX Controls, too)
So... a friend wrote code that stretches or centers ActiveX Controls inside cells. Works brilliantly, except I want to apply the code to the Picture (say Picture 12) ... the Logo ...
If I could convert the Picture into an Object (similar to a CommandButton or a SpinButton, I think the code would work.
My work around had been to insert the logo as a BitMap into a CommandButton, and then apply the stretching code to the button... BUT I have image size limitations and the Bitmap is of low resolution, which makes my beautiful logo look terrible.
Any suggestions would be very much appreciated.
maybe use base64
Inserting an Image into a sheet using Base64 in VBA?
https://www.base64-image.de/

Image recolour in Excel

I have a greyscale image with some transparent sections too. I would like to recolour this within excel (based on the value that a user types in a cell or something)
Manually, all I need to do is select the picture then in the ribbon 🡒 format 🡒 colour 🡒 more variations 🡒 more colours and select appropriately. I've tried the macro recorder on these steps but get nothing useful.
Searching the web has led me to believe that the Shape.PictureFormat.Recolor method, which I'm guessing is what I want, is only availible in Publisher. I'd rather not interface with thatfor portability reasons (in case publisher isn't installed), and I'd also like this to run as speedily as possible.
I've even considered converting the image to an array of bytes, performing the required pixel manipulations then converting back to an image, but I think that'll be slow. I also don't have a clue how.
Is there a method in VBA to recolour an image in this way, leaving alpha as it is? Perhaps with the use of an ActiveX image control? Here's an example image in case it's not clear
White 🡒 Green
Black 🡒 Black
Alpha 🡒 Alpha
If you can't find a pure object model based solution, you can try to modify the document xml. It is not the easiest of solutions, but it is far easier than pixel manipulation.
Do like this:
Save your workbook without modification
Do the color change
Save the file again, with a different file name
Unzip the two *.xlsx files you created
Analyze the differences. You'll most likely find it in the drawings folder
Recreate the changes in the xml of the second file in the first one and zip it back together. If that works, you now have a theoretical way to the solution.
If you get this to work, you can automate these steps.

Found an OfficeDraw file with shapes. Can the shapes be used without continuous copy-and-paste?

I downloaded an OpenOffice Draw document with shapes I want to use (for drawing Apache Camel diagrams). I'm not very familiar with Draw, but I've used Visio; in Visio, there was a kind of file in which you could find/put shapes, then use to create drawings from those shapes. The shapes appeared in a panel left of and smaller than the drawing, and you could drag a shape from that panel to the drawing to put an instance of that shape on your drawing; the original shape remained on the smaller panel.
I think Visio called the file that held the shapes you could use a "template"; Draw has templates, but I haven't found a reference to them holding shapes to drag onto a drawing. I've tried looking it up, but am hampered by not knowing what terms Draw uses for these things. Can someone tell me whether this is possible in Draw, and what things I should look up help on? I hate to read a whole manual to find out how to use one feature, without even knowing if the feature exists...
--
I'm sorry, I should have done better describing what I have tried. The file holding the shapes is an odg file; it opens fine as a document, and the program allows me to save it as a template, but the behavior of being a collection of shapes that I can drag onto a new drawing repeatedly, without having to copy a shape each time, is not there. That's the feature I'm trying to find.
My version (LO 5.2.3.3/openSuse) allows the creation of a new shape gallery theme (see: View>Clipart Gallery), and the addition of various graphic format files to that theme.
Also, in context meni of a shape, I can edit with external program.
So, I guess, you can save the shape(s) in a file and add it to My Shapes theme.
There will be two new files in ~/.config/libreoffice/5/user/gallery with the shape(s), to backup/restore (to a new installation) or distribution (to other computers).
Edit if your version of the office suite is lacking of that menu options, maybe you can extract the shapes from the *.odg file: unzip it and look for a custom *.sdv and *.thm file in the archive.

How to get color property of a picture object in powerpoint-VBA

I am working on a CBIR (Context Image Retrieval) project,
I am creating PowerPoint slides, that include many shapes and simple pictures(e.g sun, ball, chair..).
I'm using a VBA code to retrieve the COLOR(fill,background) feature of the object/shapes in the slide.
But, I can't get it for the pictures(jpeg/wmf) objects.
How to retrieve the picture's color by VBA code? Since Clip Art is no longer available on PowerPoint, are there any other picture libraries recognized by PowerPoint?
In the PowerPoint object model, pictures are seen as sort of collections of stuff that PowerPoint knows nothing about. You'd have to ungroup the picture (or a copy of it that you later delete) in order to retrieve colors from the individual shapes within the picture. That assumes that it's a vector picture and contains only vector shapes. You can't do much at all with a raster image w/o resorting to external libraries and more complex programming.

Creating Diagram from Excel Using VB

Sorry I can't embed images, I have the links instead (... I can only post two links. I have removed the http:// substring from some of the links).
I am looking to take an .csv file (really, any file, as I am generating this myself), and create a Visio (2010) diagram out of it. I have successfully imported the excel sheet to Visio, and can create some rough diagrams, but they are not enough. This is what I'm trying to create. Here are the following tactics I have tried, I prefer the VB method, but whatever works works:
Data Graphics: This is the closest I've gotten to a solution. Basically you create shapes and you can put data in it. Problem is, the style of display available are limited, as we can see here (imgur.com/clTLcxk). After importing the excel sheet, all I had to do was drag and drop to create these shapes. The closest I have gotten is here. However, I really need the outside box (or container, for aesthetic reasons). (Some information here [support.office.com/en-us/article/Enhance-your-data-with-data-graphics-45af64a4-1dcb-4463-9a7e-67709786181c])
VB: I have been using this (msdn.microsoft.com/en-us/library/office/ff959245%28v=office.14%29.aspx). I have ran some of the example code, but I am really lost. I have run some of the example code but the only one I have really gotten to work are useless to me. Also, I don't see any API methods that actually add data to these diagrams!
So how is this done?
I would approach this problem by first defining or finding Visio masters that would the data I'm drawing to the page. In your case it looks like you'd want a master for your Foo items, and one for your Bar items.
So then you'd step through your Bars, then within each Bar you'd have one or more Foos. For each Foo, you would drop that master out, and set the text of the shape to what you want in the blue Foo section (maybe a grouped sub-shape for the Foo master), and then text in the white body.
When stepping through all the Bars, you'd obviously have to drop out a Bar shape and position/size it to contain all the Foos.