Inserting images automatically on slides referencing model #? MICROSOFT POWERPOINT - vba

I have about 100 slides here on powerpoint that look like this:
Slide example screenshot
I need to insert an image into the text box on each slide with the sizing of
height = 5, width = 3.64
and positioning of:
Horizontal = 6" / Vertical = 1.2" (Both from top left corner)
For good measure, here are all of the image format settings:
Image format settings screenshot
The image files are the same as the model number, such as MHS1306.jpg.
Is there any way to use a macro to automatically reference the model number, insert the corresponding image, and then resize it to the correct size?
All of the images are in the same folder.
The image just needs to be in that position, the text box isn't important, just shows where the image should go.
I am very new to VBA and scripts, and basically know nothing about it yet, so I would appreciate any help.
Thanks.

Related

Word VBA to return the height and width of a preselected image

I have a Word macro that changes the orientation and page size of an individual page to accommodate the image placed on the selected page. My existing macro code does the page and footer resizing correctly (footers are based on our existing footer styles), but I'd like to enhance the code to display the height and width of the selected image before the userform appears to help guide the user's page size choice.
The user could get that information by right-clicking the image, choosing "Picture...", and selecting the "Size" tab in the "Format Object" window, but I am trying to have the height/width displayed as part of the macro instead of asking the user to follow those steps.
Editors in my department sometimes encounter documents in which an image has been placed on a page that is not wide enough to accommodate the entire image, resulting in part of the image being "cut off." My plan has been to have the user select the image on the Word page, then run the macro; the image's height and width (in inches, ideally) should be displayed prior to the user to selecting the optimal page size.
I've tried working with Selection.ShapeRange or Selection.InlineShapes, but I haven't yet been able to get the current height and width of the selected image. Any help will be greatly appreciated.
Thank you,
KRS
Here's how I opted to handle this:
My macro was designed to start with the user selecting an inline shape on the Word page. With that selection, I start by setting variables for the selection's width and height in points, convert to inches, and display the results in a MsgBox:
myHeightPoints = .Height
myWidthPoints = .Width
`Convert the previously established variable to inches`
`Dim myHeightInches As Double
Dim myWidthInches As Double
myHeightInches = myHeightPoints / Application.InchesToPoints(1)
myWidthInches = myWidthPoints / Application.InchesToPoints(1)
`Trim the result to 2 decimal places`
Dim myHeightDisplay
Dim myWidthDisplay
myHeightDisplay = Format(myHeightInches, "#.00")
myWidthDisplay = Format(myWidthInches, "#.00")
`Display the result`
MsgBox ("The selected image is " & myHeightDisplay & " H X " & myWidthDisplay
& " W" & Chr(13) & "Choose a page size that accomodates the figure and its caption.")

How to replace image of a picture shape in PowerPoint?

Is there any way to replace the image of an existing picture shape in PowerPoint from code?
Thanks
If it's a linked image, either overwrite the linked image file with a new file or point the link at a new file.
Or if the shape is picture filled, you can fill it with a different picture instead. That can distort the picture if its proportions don't match the shape's proportions; instead, you can change the aspect ratio of the shape to match that of the picture if need be.
To change the picture fill, assuming a reference to the shape in osh:
With osh.Fill
.UserPicture ("C:\path\to\picture.jpg")
End With
To work out the size of the picture so you can adjust the shape to it, you can either use external image processing software or insert the picture into PPT, giving -1 for height and width parameters and pick up the .Height and .Width of the newly inserted picture, then delete it.
Or insert a new picture, pick up the old picture's size/position/other proprties and apply them to the new picture, delete the old picture, move the new one to the old one's Z-order.

Change location of buttons at execution VB.NET

I am trying to change the location and size of buttons I have contained in a panel on a WinForm (vb.NET).
Initially the buttons have a location and an image (no text), but in execution I want to set a new location and text.
I am able to set the text for each button, and as they are set to Autosize, they increase in width.
But despite I set the location by code correctly, when the buttons are displayed they "come back" to their initial position.
Any help would be appreciated.
Thanks,
IM
The following code will change the location to the co-ordinates you specify:
Button1.Location = New Point(x, y)
You must change the x,y values to the co-ordinates on the form that you want to move the button too.
The next bit of code with change the size of your button:
Button1.Height = 10
Button1.Width = 50

How to move a rotated shape to a specific location in excel 2010 using vba

I've written some VBA code that automatically creates a chart. One of the axes on this chart doesn't use normal labels but a graphic. I've stored the graphic as an image and I use the .Copy and .Paste methods to get a copy of this image onto the chart.
Here is where it gets confusing. I need to rotate the image to get it aligned with the axis (using the .rotation property). But when I set the .top and .left properties the shape doesn't end up where I would expect. In fact setting the properties to 0 and 0 doesn't do what I would expect either. I've tried changing the order of the way I set the properties on the image object but it only appears in a different (wrong) location.
I'm sure I'm missing some vital aspect of how VBA/Excel is placing the object relative to what I'm setting the top and left properties to. Basically my goal is to make the image on the left side of the chart with the same width as the plot area's height (since the image is rotated I theorize this will make it the same size).
This code does not work:
Sheets(ImageSheet).Shapes("agreement").Copy
c.Chart.Paste
c.Chart.Shapes(1).Rotation=270
c.Chart.Shapes(1).width = c.Chart.PlotArea.height
c.Chart.shapes(1).left = 5
c.Chart.Shapes(1).top = c.Chart.PlotArea.top
I've also tried this code
c.chart.Shapes(1).top = c.chart.PlotArea.top + c.Chart.PlotArea.height
because I thought maybe it was calculating the "top" as the upper-left corner of the image object when it is not rotated (rotating 270 degrees makes this point in a place where it should align with the bottom of the plot area). But that doesn't do what I expected either.
The image is a skinny rectangle that acts as a label for the axis. The chart will end up being laid out like this: http://imgur.com/NrSXR and the axis label image would be something like this http://imgur.com/08EWU
What am I missing here?
Is it possible for you to align your chart into a position where the shape could rest align/on a cell?
IF YES then here is a suggestion:-
You could position shape into a cell. Then adjust the size to what you need. And rotate.
Then change its bring forward property be shown on the Chart.
Next Group Chart and the Shape
PS: I recorded a macro. However it's best if you could show us what your the exact picture (=how your sheeet/chart/image should look like) of your question.
I ended up rotating and resizing the image before copying and pasting to the chart and then positioning it. I had to use the IncrementLeft and IncrementTop methods rather than setting the left and top properties directly because that did not have the desired effect.
When doing the paste into the chart the object always ended up in the upper left hand-corner so I could increment to the left by the small amount I wanted as a margin I wanted there and increment the top by the value of PlotArea.top to align it with the plot area.
I was also surprised that when creating the copy of my image it retained the "name" i referred to it as when I copied it to the new sheet and chart. This was especially useful for positioning the image once it was on the chart.
I also needed execute this code at the very end of my procedure, after everything else had been positioned and aligned, or when I positioned the data labels for one of my series they wouldn't appear correctly.
Here is the code that I ended up using:
'make a copy of the label image and refer to it with a variable for convenience
Sheets(ImageSheet).Shapes("maturity").Copy
i = Sheets(ImageSheet).Shapes.Count
Sheets(ImageSheet).Paste
Dim axisImage As Shape
Set axisImage = Sheets(ImageSheet).Shapes(i + 1)
'rotate and resize the image
With axisImage
.Rotation = 270
.width = c.Chart.PlotArea.height
End With
'cut and paste the new image to the chart
axisImage.Cut
c.Chart.Paste
'position it in the chart using IncrementTop and IncrementLeft because setting the properties directly does not have the desired effect
c.Chart.Shapes("maturity").IncrementTop c.Chart.PlotArea.top
c.Chart.Shapes("maturity").IncrementLeft c.Chart.PlotArea.left - c.Chart.Shapes("maturity").height

itextsharp: getting height of image

i need to add a data table right after an image on a PDF in vb.net
last_pos=jpg2.height
datatable.WriteSelectedRows(0, -1, xpos, last_pos, writer.DirectContent)
unfortunately this is the output:
i highlighted broccoli, buckwheat, butter, cabbage. these are all part of a data table that is supposed to go after the bottom SEVERE word because the entire thing that you see is one image called jpg2
alt text http://img710.imageshack.us/img710/3661/fullscreencapture121520.png
If you are using .ScalePercent to stretch the image (I suspect this based on some of your previous posts), the actual dimensions of the image object do not change after you have applied .ScalePercent to it. To get the displayed height of the image, you will have to:
jpg2.Height * my_scalefactor