Using Microsoft PP Functions in vba code? - vba

I wrote a vba macro for PowerPoint. All works well but I miss one step.
So far my macro ends by selecting a certain group of shapes on a slide. After it finishes I go back to PowerPoint and use the "Group" button to make a group out of the selected shapes.
How can I use this Micorsoft Group function in my code. I only manage to group all shapes on a slide to one group or I get an error.
I have tryed:
ActivePresentation.slide(1).shapes.selected.group
but that doesn't work.
I have read this:
How do I group a set of shapes programmatically in excel 2007 vba?
but several names of shapes are identical, so that doesn't really work. And I do not know how to store the indexnumber of a shape into a variable - which would be a second option to solve my problem.
Basically the Microsoft own functions does exactly what I would need now, right? I takes the shapes that are selected and groups them to a group. can I just call this function within my macro?
Many thanks for any help.

If you've got the shapes selected, then this should do it:
Activewindow.Selection.ShapeRange.Group

ActivePresentation.Slides(1).Shapes.Range(Array(2, 3, 4)).Group
ActivePresentation.Slides(1).Shapes.Range(Array("this", "that", "other")).Group
ActivePresentation.Slides(1).Shapes.Range(Array("this", 42, 3)).Group

Related

Coyping grouped images as picture and crop it in ppt via vba

I have a problem to get a certain amount of shapes in ppt to a certain format. I generate them via nprinting and they are already grouped properly. The problem is that I can´t crop them once their grouped. If they are not grouped I can address each of them individually and crop them the way I want. I need them in picture(u) format in order to be able to crop them. My approach was to cut them and insert them again but as picture. Unfortunately I wasn´t able to cut and paste them via vba with the code below. Does anyone have an idea how to solve this?
Dim myDocument As Object
Set SlidePPT = objPPT.Presentations(FilePPT).Slides(7)
SlidePPT.Select
myDocument.Slides(7).Shapes.SelectAll.Group
Selection.Cut
myDocument.Slides(7).Pictures.Paste
myDocument.Slides(7).Shapes(1).PictureFormat.CropBottom = 200
The alternativ I had in mind was to crop it first and Group it then, but this seems not to work either.
edit: Okay, it seems that the problem with my alternative approach is, that my code just selects all of the shapes but does not group them. Any ideas on that?
Solved it. i just needed to add the range.
myDocument.Slides(7).Shapes.Range.Group

Create a VBA Macro to create BoxPlot Charts

I am a beginner in VBA, so be indulgent in my lack of methodology while working on some VBA macro for Excel.
My goal is to create some BoxPlot Charts in Excel at this time, I have been able to create some For/If loop to capture the Data in my different worksheets (ex: I have a Ftotal column in each worksheet, but from different length that I want to add to my boxplot). For some graphs (xlcolumnclustered, ...) I have been able to simply write:
ActiveChart.ChartType = xlColumnClustered
But, when I want to do it for a box plot (xlboxwhiskler) I have not been able to complete it. So I have tried to record a macro while I was creating a box plot graphs in a chart sheet and I have been able to capture:
ActiveSheet.Shapes.AddChart2(406, xlBoxwhisker).Select
Which is not working when I am runing my Macro. Btw way, I can't figure our why I get an Activesheet instruction whereas I was on a chart page (seems strange to me, I was expecting an ActiveChart).
So my question are:
Is there a xlboxwhiskler working to create a Box Plot Chart ?
If not, is there another way ? (I have some info from here and here). Just FMY, why is Set used for ?
Finally my last solution is about to calculate everything (it might be challenging to do so), but the link here might be useful
If you have any suggestion, I remain open for it. It will then post my solution.

Determining the order of shapes in a Word document

I have a word document that contains text boxes (about 30 of them) that are moved around. I need to know the order of the boxes.
In Word 2016 Activedocument.Shapes returns the shapes in the order they appear in the document, however that is not the case for Word 2007 (they are in the order they were added). Since I want it to work in Office 2007 I'm looking for a workaround.
I use box.wrapformat.Type = WdWrapType.wdWrapInline to convert the boxes to act like inline shapes since .ConvertToInlineShape isn't available in office 2007 but this doesn't actually convert them to inline shapes.
Edit: I just noticed neither does .ConvertToInlineShape. The box doesn't appear in the InlineShapes collection but if I select it the selection type is wdSelectionInlineShape.
Is there a way to force Word to reassign the shapes in the shapes collection or is there another way to get references to the shapes in the correct order?
I am thinking about looping through the characters of the document (selecting each and checking the type) but this seems rather slow.

Excel VBA - a macro to 'Format Data Series - Gap Width' in a chart?

I have to change the design of about 100 charts in Excel 2011, and I'm trying to speed things up a little with macros.
The problem is that Excel doesn't want to simply record some actions into a macro, it seems they need to be manually written.
I've managed to make a macro for changing the formatting of Data Labels using tips from this thread:
Formatting data labels in Excel charts using VBA
But now I'd like to also edit Label Series- Gap Width percentage, through a macro. I don't know the exact VBA syntax for this action. Maybe someone here can help.
I've tried
ActiveChart.SeriesCollection(1).DataSeries.GapWidth = "110%"
But it didn't work. Run-time error 438, Object doesn't support property or method.
Does anyone know the correct syntax?
You can try the following code:
ActiveChart.ChartGroups(1).GapWidth = 110

Word 2007 Vba - Go to placeholder via macro

Ok, So I'm constantly battling with Microsoft as I'm creating several templates for a few customers. My problem is this, simple textbox placeholders scattered all around a document allows me to press TAB to go to the next placeholder. Much like Tab order in Visual Studio. But for some strange reason, this doesn't work with rich textbox placeholders. And I need to use rich text for a few textboxes because the user should be allowed to alter the formatting of single characters. This is not possible with simple textboxes.
So I was thinking, could this be possible using macros? For example, if a textbox placeholder is selected and the macro is run, go to the next placeholder?
The Shape/TextBox objects can be accessed through
ThisDocument.Shapes.Item(index)
and checking the returned Shape object for
theShape.Type = msoTextBox
However, the Shape objects will be returned in the order that they were created, not their order on the page/document. To find the 'next' TextBox, you are probably going to have to loop through all TextBoxes and investigate their location (.Top, .Left etc) in order to find the correct one to move to with:
theNextShape.Select