Convert an embedded Excel Picture into an Object - vba

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/

Related

How do I Resize An Image In a RichTextBox?

this might sound like a repost of a question already asked. However, I have spent a few days looking through and testing many different examples from a number of different websites (incl. stackoveflow.com). Up to now, I got mostly undesired results and am a bit lost as to how to achieve this or something which produces good results? If anyone is able to help I would greatly appreciate it!
I work in VB.NET and use Visual Studio 2015.
My objective is to get a crisp image in the resulting RTF file when I open it in a text editor (I use WPS Office). However, the low quality, out of focus image I have been getting in the final RTF document is not a good header for the description I want to use it for! Nor will it look good after printing! I am not looking for a thumbnail image as the image is required for a larger document header.
Most solutions I have tried deal with resizing an image and then pasting it into a Rich Text Box(RTB).
However, although I have tried using interpolation, antialiasing, etc., the results are not great. For resizing, I have tried examples which use division, percentage, etc.
I am working on an app for my own personal use that "pastes" a screenshot of an active solution/app (i.e. bitmap) into a Picture Box(PB) and into an RTB using the clipboard, title is appended then text added manually in the RTB and the result is saved as an RTF file.
Image Quality issues I have found:
Pasting an image after resizing/scaling the original (or a copy) in the Picture Box reduces quality?
Saving to an RTF file or opening the RTF file in a text editor reduces quality? (Not sure which causes the issue?)
Both these processes result in a low quality, out of focus image (with or without interpolation, smoothing, antialiasing, etc.)? So, it seems to me that resizing before pasting reduces quality. I have tried pasting directly from the clipboard and also copying the image from the Picture Box to clipboard, then pasting to RTB. Both these procedures produce good results!
To be objective, I cannot share all the code I have tested, but share below a simple example of code which produces the best image quality for me, i.e. just simply pasting the screenshot directly from the clipboard to the RTB. However, the resulting image after pasting into the RTB has not been resized and is therefore too big. I don't want to manually resize the image in the RTF document as this would be an extremely repetitive task!
After pasting the bitmap into the RTF, I have used the Select All or Selection Start - 1 methods to select the image in the RTB, but to frame my question, "How can I resize the image in the RTB?"
You might ask why I want to do this. Well, pasting the bitmap directly into the RTB gives me the same quality image as the one in the Picture Box. There is a slight loss after saving to an RTF file and opening it in a text editor, but the quality is much better than the other methods mentioned above (i.e. resize then paste)! So, I got curious to attempt to paste and then resize! Here is my code:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
'Check whether PB1 is empty:
If PictureBox1.Image Is Nothing Then
'Get image from clipboard to PB1:
PictureBox1.Image = My.Computer.Clipboard.GetImage
'Resize image to fit PB1:
PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage
'Paste image:
RichTextBox1.Paste()
End Sub

Picture Transparency Object in PowerPoint 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.

Extract screenshot or picture of portion of PDF using VBA or VB and Adobe SDK

I am currently using an excel macro (although I will switch to VB.NET if necessary) to loop through all of the text in a PDF and populate an array with certain portions of the text in the PDF (via the Adobe SDK and getPageNthWord). This part is working just fine, but now what I want goes a step further.
There are certain portions of the PDF where just grabbing the text isn't giving the full picture, and I'd like to see what more I can get. This is exactly the screenshot or snippet I am trying to get:
So, I know that I could use getPageNthWordQuads to find the coordinates for the words "Compliance Warning" and I could figure out a way to find the bottom right of the screen as well, but my problem starts there. After I get those coordinates what would I do with them? Can I zoom in the PDF to only see that portion and then take a screenshot? I already have the code for a screenshot of the activewindow, but I don't know how to scroll or zoom on a PDF.
Any help would be greatly appreciated. A fresh approach would be welcome as well. Thanks!
There are probably a number of approaches that would work - I don't know enough about your environment / constraints to know for sure which would work best. I'm assuming you are talking to Acrobat through OLE here.
1) You can open a window, get its AVPageView and ask it to zoom and move to where you want it to do your thing.
2) You can open a PDF document in one of your own windows using OpenInWindowEx and then grab the contents of that window (the advantage being that this window could be off screen).
3) You can use the DrawEx method (in AcroExch.PDPage) to render a specific portion of a page into your own window and then process that.

A Text value change on Powerpoint by using OpenXml doesn't fit

I use OpenXml for creating custom powerpoint presentation in this way: I put a keyword on the presentation, I found it during process with OpenXml and change the text value. Everything work fine but the fit option doesn't work at first.
The text box has options "Autofit: Shrink text on overflow; Wrap text in shape: On"
After my process, the new text appear on the right place but the autofit is not done, I need to click on the text box and make a input for see the autofit work. I think that PowerPoint only check option after a modification.
What I want is the autofit option is called at the end of the process. Can anyone help me?
I hope you understand what I want to do.
Thanks.
It's not possible using just OpenXML. The <a:normAutofit/> tag is used by a client application, such as PowerPoint, to render the text larger or smaller, as needed. OpenXML doesn't actually render anything, so until the client does, it will just read the text as if it is not auto-fitted.
There are a few options to think of to control this - none of them great however. One would be to use VSTO or VBA in PowerPoint to check all shapes on PPTX open and if they have a AutoFit tag, to re-render them. A second way would be to do all the font measurements yourself based on the shape's width & height and then set the font scale to the appropriate percentage. Another would be to make a textbox large enough to fit the largest amount of text you will ever insert and then turn autofit off.
Sorry this doesn't really help you immediately. I've done tons of research on this particular subject and it's all bad news.

save textbox as picture in powerpoint_transparancy difficulties

In powerpoint 2010 I want to save an inserted textbox as a picture, which is simply done by right-clicking on the text box and save it. The saved image will however include a large amount of transparancy around the text. I am wondering whether this abundance of transparency around the text can be reduced, whithout using photo-editing programs.
I understand that powerpoint is not the right tool to use the beautifuly created texts for other purposes aside from office itself, however this would make things ten times easier for some coworkers of mine.
I hope someone can help me with this, also if it means using VBA or other (complex) codes/languages.
Thnx for your time.
Mike
Once you have typed your text in the textbox,
Copy the text box, right-click and paste as image
Now you have the image of the text box as you will get while saving that textbox as image - - using the save_as_image option
Select this image and click on format tab
You have an option to crop your image
Crop the image and save it as a picture