Reusable / dynamic / instance / symbol object (hack) in PowerPoint? - powerpoint

I've been searching for a while and can't imagine that there isn't a way ...
Is it possible to create an object in PowerPoint, and create "dynamic copies" of that that will ALL change when you edit one?
Like what in Flash used to be called an "instance" (and object oriented programming OOP in general? not sure) .
Like what in
Illustrator is called a "symbol".
In Sketchup a "component" has this behavior.
In Revit a "group" sort of tries to do this in a terrible
way.
Even a way to link an external (vector or raster image) file would be fine as a workaround, but not even that is possible in PowerPoint?!
Many thanks!//r

I just make all the shapes of one type have the same name, e.g: Menu_BTN in my shape's selection pane.
And if I want to change the colour of those buttons spread over 100s of slides, I use the following macro:
Sub ChangeMenuBTNColour()
Dim ppt As Presentation
Set ppt = ActivePresentation
Dim sld As Slide
For Each sld In ppt.Slides
Dim shp As Shape
For Each shp In sld.Shapes
If shp.Name = "Menu_BTN" Then
shp.Fill.ForeColor.RGB = RGB(252, 225, 212)
End If
Next
Next sld
End Sub

Related

Programatically Removing and Replacing Watermarks in Word

I'm trying to do some standardized document manipulation specifically in a Windows environment on Word documents. For frustratingly silly reasons, I'd also like to do this in VBscript or at least language tools available in Vanilla Windows 10 + Office.
As it stands, the documents coming in all have a standardized text Watermark on them, and I'd like to replace that watermark with a new text watermark. From what I've been able to gather, the watermark is some sort of generalized shape object. I've had some fiddly success finding and deleting all shapes, but it's not clear to me if there is a way to inspect each shape and determine if it is the correct shape in VBscript, or to replace the text hiding somewhere within the shape structure to produce a new watermark.
My deletion looks something like the following, where lDoc is a document object of document I'm manipulating.
sub UpdateWatermark(lDoc)
Dim section
Dim hdr, hdr_rng, sp, str
dim cnv
dim rng
for each section in lDoc.Sections
for each hdr in section.Headers
For each sp in hdr.Shapes
if InStr(sp.Name, "PowerPlusWaterMarkObject") > 0 Then
sp.Delete
End if
next
next
next
end sub
The strange thing with this brute force deletion approach is I'm seeing many PowerPlusWaterMarkObjects in the header, but only one is the "for real" watermark. I also am not sure how to create a new object and insert it with the same properties as the one I'm deleting. My preference would be to simply find the watermark object and manipulate it directly. Any Guru's out there who could lend me a hand?

Variable Increase in MS PowerPoint

I've very limited knowledge of PowerPoint but have been asked to create a presentation slide where I would have to click areas on a map and that would change color and increment a number (population). I am able to change the color of the map on click and I'm able to display a bubble but I am not able to increment the population number based on the areas of the map that are clicked.
I've looked at some solutions around here and did some research online but couldn't find anything that would point me in the right direction.
Is there a way to create a variable and pass a number when you click a specific area of the map, which is a Freeform.
Thank you in advance for the help.
You can set each shape's Action Setting to Run Macro: (macro name)
That will run the VBA subroutine called (macro name) when you click on the shape during a slide show.
Mac PowerPoint has a few bugs that keep this from working as smoothly as it does in Windows PowerPoint but the code below works around these issues and works in either version.
Sub IncrementNumber(oSh as Shape)
Dim oSl as Slide
Dim oShTemp as Shape
' oSh.Parent returns a valid reference to the shape's host slide:
Set oSl = ActivePresentation.Slides(oSh.Parent.SlideIndex)
' and oSh.Name works as well
' So we use those two bits to get a reference
' to the clicked shape like so
Set oShTemp = oSl.Shapes(oSh.Name)
With oShTemp
.TextFrame.TextRange.Text = _
Cstr(CLng(oShTemp.TextRange.Text) + 1)
End With
End Sub
About this bit:
Cstr(CLng(oShTemp.TextRange.Text) + 1)
This gets the current text in the shape, converts it from text (string) to a number so we can do arithmetic on it, adds 1 to it, then converts it back to text so we can plug it back into the shape's text.
If you don't know what to do with VBA code examples, there's a tutorial on the PowerPoint FAQ site that I maintain:
How do I use VBA code in PowerPoint
http://www.pptfaq.com/FAQ00033_How_do_I_use_VBA_code_in_PowerPoint.htm

Scale / Resize StdPicture in VB6

I have looked far and wide and reached the end of my wits trying to figure out how to do this. I have looked on XtremeVBTalk.com and the rest of the internet on how to resize a damn StdPicture!
Does anyone know how to do this? Is this even possible?
Thank you so much in advance. I desire not to use any type libraries etc. so if that is offered in a solution I don't think I will be able to use it.
I'm not using A picturebox control at all.
Say I have the following function header, and an StdPicture is passed in:
Private Function EncodeImageToBase64(ByRef Image As StdPicture) As String
I then have the following declarations where I intend on encoding the StdPicture to base64:
Dim xmlDoc As DOMDocument60
Dim xmlNode As MSXML2.IXMLDOMElement
Dim bColor() As Byte
Dim bMask() As Byte
Dim bImage() As Byte
Dim lCrcTable() As Long
Dim lWidth As Long
Dim lHeight As Long
EncodeImageToBase64 = vbNullString
If Image Is Nothing Then
Exit Function
End If
Call CRCTable(lCrcTable)
Call Icon2Arrays(Image, bColor, bMask, lWidth, lHeight)
If Not CreatePngByteArray(bImage, lWidth, lHeight, bColor, bMask, lCrcTable) Then
Debug.Assert False
Exit Function
End If
However, before calling that, I want to cut the image's width and height in half. How can I do so? CreatePngByteArray only supports 16x16 PNGs and I am using 32x32, so I'd like to cut them down in order to pass the asserts they have.
OK, I spent quite some time that I didn't really have on this one, because I didn't know the answer to begin with, but I was still interested in finding out what the potential solution was.
The following answer is my understanding of what you are trying to do, but may not be the answer to the question itself, so it could very well be considered wrong.
So, here's what I came up with. You will need to use an IPictureDisp object instead of an StdPicture object. You will also need to use a PictureBox control, even if you don't really want to.
Create a new project. Add a form, or open an existing one if one is provided. Set the ScaleMode of the form to pixels. Add a PictureBox control on the form. Set the AutoRedraw property of the PictureBox control to 'True', the BorderStyle property of the control to 'None', and the Height and Width properties of the control to 16 pixels each. Add the following code to the form, and modify the location and type of the image that you want to resize, and then the location to save it to:
Private Sub Form_Load()
Dim TestPic As IPictureDisp
Set TestPic = LoadPicture("C:\Users\Your Name\Desktop\image.gif")
With TestPic
.Render Picture1.hDC, 0, 16, 16, -17, 0, 0, .width, .height, 0
End With
SavePicture Picture1.Image, "C:\Users\Your Name\Desktop\image2.bmp"
End Sub
The image can start with any of the types that Visual Basic 6 supports (.bmp, .cur, .gif, .ico, .jpeg or .jpg, and .wmf), but must always be saved in bitmap format. Please note that Visual Basic 6 does not support PNG file formats at all, so you will not be able to use any VB6 functions to open PNG files or create them.
I would be interested in other solutions that other people come up with.
Edit: Fixed dimensions.
Do you mean inside the PICTUREBOX control or inside an IMAGE CONTROL? Because If I remember correctly it has a STRETCH property which autofits the image to the container
#Zaf Khan beat me to it. I have something similar where I have a PictureBox. Under behaviour I have SizeMode set to StretchImage then when I load an image like so
LoadWebImageToPictureBox(ImagePreview, SelectedFile)
it auto fits.

Is it possible to use VBA to ungroup an EPS picture to create a Microsoft Office drawing object in Word?

Ungrouping an EPS picture, converting it to a Microsoft Office drawing object in the process, is possible in PowerPoint as follows:
oShp.Ungroup
and Excel like this:
Selection.ShapeRange.Ungroup
But the closest I can get in Word (with the non-inline shape selected in the document) is this:
ActiveWindow.Selection.ShapeRange(1).Ungroup
and this returns the error "Run-time error '-2147024891 (80070005)': Group is locked and cannot be ungrouped".
Yet when I right click on the EPS picture in the document and select Ungroup, I can convert it to a Microsoft Office drawing object and then ungroup it once more to get the individual shapes.
There must be a way to do this in VBA?
You need to check if the shape is a 'Group'
Try this.
Sub Sample()
Dim shp As Shape
For Each shp In ActiveDocument.Shapes
If shp.Type = msoGroup Then shp.Ungroup
Next
End Sub

how to extract list or bullet details from .pptx or .ppt file using c#

I am using Microsoft office Interope assembly to extract features from .pptx and .ppt files using c#. I was able to extract details about shapes, animations but not able to extract details about which types of bullets ppt or pptx consists of or which slide contains bullets etc.
Please help me finding this.
Thanks in advance.
In VBA, you'd do something like this to examine the bullets on slide 1
Dim oSh As Shape
Dim x As Long ' Integer in C#?
For Each oSh In ActivePresentation.Slides(1).Shapes
With oSh
If .HasTextFrame Then
If .TextFrame.HasText Then
With .TextFrame2.TextRange
For x = 1 To .Paragraphs.Count
Debug.Print .Paragraphs(x).ParagraphFormat.Bullet.[Various properties]
Next
End With
End If
End If
End With
Next
Look at the code in the PPT VBA editor. When you type the dot after Bullet above, intellisense will show you the available properties.
There are a few ways. In the code below, you can see the properties of the text that you can access in your program:
ppTextBox.TextFrame2.TextRange.ParagraphFormat.Bullet.Type =
Office.MsoBulletType.msoBulletNumbered;
ppTextBox.TextFrame2.TextRange.ParagraphFormat.Bullet.Style =
Office.MsoNumberedBulletStyle.msoBulletAlphaLCParenBoth;
ppTextBox.TextFrame2.TextRange.ParagraphFormat.Bullet.StartValue = 4;
ppTextBox.TextFrame2.TextRange.ParagraphFormat.Bullet.UseTextColor =
Office.MsoTriState.msoTrue;
ppTextBox.TextFrame2.TextRange.ParagraphFormat.Bullet.UseTextFont =
Office.MsoTriState.msoTrue;
where ppTextBox is a shape object, and note the use of TextFrame2 rather than TextFrame. You can interrogate the ParagraphFormat.Bullt.Type against the enumerated list Office.MsoBulletType to see which has been applied.
For more details, check this page for more details on text processing in powerpoint with C#.

Resources