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
Related
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.
Can someone help me with a code for capturing a 250X250 pixcel screen and copying it into clipboard. I would like to paste the image into an excel i can code that part. I have no clue where to start. I have made a code till reframing on the a point where i need the macro to capture.
Dim objviewer3d as viewer3d
Selection1.search("Name="+Textbox1.value+"*,all")
Caita.startcommand("reframe On")
Catia.refreshDisplay=true
Set objviewer3d=catia.activewindow.activeviewer
Objviewer3d.viewpoint3d.zoom=0.017
objviewer3d.update
This is the code i have written. I need the capture code. I Have no clue how to do that. And Last thing I know code to capture full screen and capture to file code. I don't want that.
Thank you
The CATIA method which captures the current window to a file is Window.CaptureToFile:
CATIA.ActiveWindow.ActiveViewer.CaptureToFile catCaptureFormatJPEG,"C:\Temp\Capture.jpg"
This captures the entire window, so to make it 250x250, set the ActiveWindow.Height and .Width to 250 before capturing the image. Then set it back afterwords to it's original size only. Alternatively you can resize the image after you insert it into Excel as a shape.
If you want the tree off you can also call ActiveWindow.Layout = catWindowGeomOnly
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
I have another challenge. Has anyone tried to intercept the copy/paste events? My goal is to prevent someone from cut/copy/paste a shape that is already on a sheet. If they drag it from a stencil, that is fine. I just can't have them duplicate an existing shape. To make this a bit harder, it is only the shape that I need to prevent. If the want to copy text, that is fine.
We have a order type database that contains items that need to be dropped on a Visio sheet. I cannot use the shapeID because I need to be able to update the shape from the database and I can't write the ID back to the database as it is against security policy. The way that I am tying the two together is a property named shapeKey and that value is provided by the database at the time the shape is dropped.
When a use needs to refresh the sheet from the database, I interate through the shapes, comparing the shapeKey in the shape and in the database. if there is a match, I do an update of the other properties. If there is no match, I want to delete the shape. if a user copies a shape, the shapeKey will also be duplicated and that causes problems. Lastly, they can add their own shapes from stencils and those shapes must be excluded from the delete process
I have two options:
Disable shape cut/copy/paste
Intercept the copy/cut and when they paste, change a property so that I know that it was a user pasted shape. This is preferred because it is more user friendly
I just thought if another way I that might work. Is there a way to lock the shapes to prevent the copy? If there is a lock, would that also lock the location? The user needs to be able to most the shapes around.
I thought about capturing the event but I could not find the event codes to look for. I cannot install the Visio SDK which has the Event monitor. The monitor might have shown me the code. Here is some pseudo code as to what I think would be the flow.
option 1
if select item is a shape then
msgbox "shape copying verboten. please us the stencil"
clear selected item
option 2
capture the paste event
if selected item is a shape then
vsoShape.Cells("Prop.ShapeKey").Formula = Chr(34) & "protect" & Chr(34)
Layers might work. All the database controlled shapes can be on one layers and all the user shapes on another but I haven't worked with layers before. would that work? How can I be sure that any shape pasted goes onto the user layer?
Thanks all! I did find a solution and it was really elegant. I found the idea here and changed it to what I needed:
Shape added event: https://msdn.microsoft.com/en-us/library/office/ff767288.aspx
Here is what I came up with:
Private Sub Document_ShapeAdded(ByVal vsoShape As Visio.IVShape)
If vsoShape.CellExistsU("Prop.ShapeName", 0) Then
vsoShape.CellsU("Prop.ShapeName").Formula = Chr(34) & "ShapeName" & Chr(34)
End If
End Sub
The interesting thing is that it doesn't fire if I add the shape via VBA. That is perfect for what I need but I would have thought that dropping a shape is adding a shape. I am only looking for one property because not all shapes on the stencils come from a database and for those objects, I don't need to do anything.
It was not the solution that I expected but it works really well.
I am writing a macro in VBA for excel in which I would like to change the transparency of the lines connecting markers in a series but leave the transparency of the markers in the series the same.
To specify: the chart is a scatter plot. I would like the markers for a series to be opaque/zero transparency and for the lines in the series to be 75% transparent.
I have adjsuted the transparency of the lines by using
myseries.format.line.transparency = 0.75
but this changes the marker transparency as well.
does anyone know of a way I can change the transparency of the two separately? I imagine there is a member/property to do what I want, but I cannot find it.
thanks in advance for any help!
This answer isn't going to make you very happy.
I've looked into this before and the information i've gotten is that this simply isn't a parameter that you can specify through VBA. It looks like you can access marker style, size, background color and foreground color, and that's about it.
Maybe MS didn't think anyone would ever want to mess with that.
One thing you could try is applying a custom chart format, but if you have variable numbers and/or orders of series then that may not work.
mychart.ApplyChartTemplate ("filepath\filename.crtx")
Something like that, where mychart is already set equal to the chart you want to format.
Again, maybe not of any use to you, best i could think of.
You guys didn't dig hard enough.
SeriesCollection(i).Format.Line.Transparency
will work if the SeriesObject is in a certain state. The original 'automatic' line style state prevents this vba from doing anything at first, but if you simply precede it by setting certain other properties on the line format first, then the transparency will take. The following worked for me:
For Each obj In myChart.SeriesCollection
obj.Format.Line.DashStyle = 1
obj.Format.Line.Transparency = 0.65
Next obj
DashStyle = 1 sets the line style to 'Solid' (as opposed to dashed, dotted, etc.) and has the side effect of freeing up the series format to have the transparency set. I don't know for sure why it works, but it does.
Sorry, my mistake. I read the question slightly wrong.
I find that if I start the line with no markers, then turning transparency separately doesn't turn the markers on and off.
Try this:
activechart.SeriesCollection(1).format.fill.transparency=0.5