Set the font of PPT text from VBA Excel - excel

I am trying to copy the excel content to PPT. using this command
`pptSlide.Shapes.PasteSpecial DataType:=ppPasteHTML, Link:=msoFalse '2 = ppPasteEnhancedMetAEile
Set myShape = pptSlide.Shapes(pptSlide.Shapes.Count)
If myShape.Height <> ExcRng.Height Then
myShape.Table.ScaleProportionally ExcRng.Height / 285
End If`
While I am doing it sets the font of the content gets bigger or smaller depending on the amount of text in the shape.
Can some one tell me if I can fix the size of the font to "8" irrespective of the amount of content.
Since its not a textarea but just a shape.

Shapes containing text in Powerpoint have the property Autosize:
ActiveWindow.Selection.ShapeRange().TextFrame.Autosize = ppAutoSizeNone
With this you can make the text stick to the size you determine in
ActiveWindow.Selection.ShapeRange().TextFrame.TextRange.Font.Size

Related

Shape size in centimetre not consistent

I create a shape in Excel specifying certain dimensions:
With ActiveSheet.Shapes.AddShape(msoShapeRectangle, 96, 30, 144, 60)
.Height = Application.CentimetersToPoints(2) '2cm height
.Width = Application.CentimetersToPoints(4) '4cm width
End With
I then print the sheet as a PDF document using Adobe PDF printer. (Excel sheet size and printer sheet size are both set to A4).
The problem is that the size of the shape on the PDF is not the same as what is in Excel. On the PDF the width and height are different.
What is causing this problem and how do I fix it?
Edit:
Shape in Excel
Shape in PDF, measured using Adobe Acrobat measuring tools
Many thanks!

Pasting images (excel Table) in PowerPoint

I'm trying to paste excel table as picture into PPT though VBA
but the images are not in the desired shape as codded
The Require coordinates are:
Height 14.80
Width 23.28
Top 2.13
Left 5.3
and the output coordinates are like:
H-18.73 CM
W-23.28 CM
Horizontal-5.3 CM
Vertical-2.13
below is my code:
Range(cel.Value).Copy
newPowerPoint.ActiveWindow.View.GotoSlide cel.Offset(0, -1).Value
Set activeSlide = newPowerPoint.ActivePresentation.Slides(cel.Offset(0, -1).Value)
activeSlide.Shapes.PasteSpecial(DataType:=ppPasteEnhancedMetafile).Select
newPowerPoint.ActiveWindow.Selection.ShapeRange.Height = Application.CentimetersToPoints(14.80)
newPowerPoint.ActiveWindow.Selection.ShapeRange.Width = Application.CentimetersToPoints(23.28)
newPowerPoint.ActiveWindow.Selection.ShapeRange.Left = Application.CentimetersToPoints(2.13)
newPowerPoint.ActiveWindow.Selection.ShapeRange.Top = Application.CentimetersToPoints(5.3)
Good workaround is to place a shape where you want it and use Debug.print to read the position in points.

How to increase the size of a checkbox?

I'm trying to increase the size of a checkbox in my Userform.
In the properties tab, I can change the height and the width of the object but it doesn't change the size of the square. I add a picture to explain my issue.
Thank you.
#Portland Runner's comment is a good suggestion. For example, in the click event of the label (using WingDings 2) ...
Option Explicit
Private Sub Label1_Click()
If Label1.Caption = "Q" Then
Label1.Caption = "R"
Else
Label1.Caption = "Q"
End If
End Sub
There are 2 problems with the VBA checkbox:
The size of the square
The size of the caption text
My solutions:
Create a frame in which you put the checkbox object. A frame has the property Zoom. Set that property at whatever value you want. Then change the font size of the button to match the rest of the fonts in the form. The frame doesn't have to have a title, and you can select an invisible border for it. In that way, the user doesn't see it.
For whatever reason, the checkbox's text looks smaller than the rest of the objects, even though it is the same font size. My solution for this was to remove the checkbox's text and add a standard label object to the right.

How to set or modify the font size from a chart embedded in a userform

I'm programming an userform to show a graph with data stored in a range of cells, but when the graph shows it is so small and it gets impossible to read, and it shows another label with "series 2" even when i didn't added it.
I tried changing the properties of the image box, from "0 fmPictureSizeModeClip to fmPictureModeZoom but it only makes it blurry, i tried to modify my code adding:
MyChart.Parent.Width = 1200
MyChart.Parent.Height = 780
But it only the bars get big and the labels and title keeps small, and being unable to read.
Set MyChart = ActiveSheet.Shapes.AddChart(xlColumnClustered).Chart
MyChart.Parent.Width = 1200
MyChart.Parent.Height = 780
MyChart.SeriesCollection.NewSeries
MyChart.SeriesCollection(1).Name = ChartName
MyChart.SeriesCollection(1).Values = ChartData
MyChart.SeriesCollection(1).XValues = ActiveSheet.Range("K32:K43")
This is the userform after adding:
MyChart.Parent.Width = 1200
MyChart.Parent.Height = 780
and this is before it, as you may see the text is illegible, the name of the chart in the screenshot disappeared but i corrected the code and now it appears but just as small as the other text in the chart
If complementary info needed i will gladly provide it,
any help is appreciated.
I figured out the answer.
MyChart.Axes(xlCategory).TickLabels.Font.Size = 20
MyChart.Axes(xlValue).TickLabels.Font.Size = 20
MyChart.Legend.Font.Size = 20
MyChart.ChartTitle.Font.Size=24

Applescript - Preserving Image Dimensions When Inserting Images into Excel

I am currently in the final stages of creating a workflow for a very tedious and drawn-out weekly process involving using data in an excel to insert images.
I have managed to work out a combination of Automator and Applescript to achieve a workflow that gets the images in the excel, in their proper place but with my current applescript, they are coming in at a set size, 100 x 100
Here is the issue:
I need all of the images to come in at a height of 100px but I need the width to be flexible. I can't seem to figure out the last piece of this which I assume would be an Applescript command for excel to lock the aspect ratio.
Here is the current applescript I am using for the actual image import:
tell application "Finder"
set imageFolder to "Macintosh HD:Users:adlife:Desktop:Temporary_Image_Hold - Copyright Filings"
end tell
tell application "Finder"
set imageList to files of folder imageFolder
end tell
tell application "Microsoft Excel"
set imageHeight to 100
set imageWidth to 100
set imageCount to count of imageList
set theRange to active cell of worksheet 1 of workbook 1
set thisStep to 0
set theLeft to left position of active cell
repeat with imageFile in imageList
set theTop to (top of active cell)
set newPic to make new picture at beginning of worksheet 1 of workbook 1 with properties {file name:(imageFile as text), height:imageHeight, width:imageWidth, top:theTop, left position:theLeft, placement:placement move}
set thisStep to thisStep + 1
end repeat
end tell
I am running Microsoft Excel 2011 on El Capitan
Any help here would be greatly appreciated!
Thanks!
There is no image property to force the aspect ratio. The check box in user interface is to lock the ration when user moves or resize the image.
The solution is to get image dimensions and apply the ratio (width / height) to your defined image height (=100). Dimensions are provided using the "Image Events" instructions. Then you can used the new width as the "width" property in the "make new picture".
set imageFolder to "Macintosh HD:Users:adlife:Desktop:Temporary_Image_Hold - Copyright Filings"as alias
tell application "Finder" to set imageList to files of folder imageFolder
tell application "Microsoft Excel"
set imageHeight to 100
set imageWidth to 100 -- just a default value, not really needed
set imageCount to count of imageList
set theRange to active cell of worksheet 1 of workbook 1
set thisStep to 0
set theLeft to left position of active cell
repeat with imageFile in imageList
set theTop to (top of active cell)
tell application "Image Events" -- open the image and get dimensions
set theFile to imageFile as alias
set myImage to open theFile -- don't worry, it will not open the fiel for user, only for the script !
set {W, H} to dimensions of myImage
set imageWidth to imageHeight * W / H -- set width using the proportion of image = W/H
end tell
set newPic to make new picture at beginning of worksheet 1 of workbook 1 with properties {file name:(imageFile as text), height:imageHeight, width:imageWidth, top:theTop, left position:theLeft, placement:placement move}
set thisStep to thisStep + 1
end repeat --next image to place
end tell
I tested that script (of course with my own image folder !), and it works with El Capitain and Excel 2011.
As you can see, I also changed the first lines of your code:
To Set imageFolder, you do not need to do it in a tell "Finder" block.However, it must be set as "alias".
To get all files, you can tell "Finder" in single line, without tell / end tell block. (more simple)

Resources