Original Image format

A

Abhishek

Hi!
Can i get to know the original image format of the image presently inserted
on the slide.
e.g I insert a Png image and a jpeg image and say a bmp.
Now can i get to know which type of image this was thru VBA so that when i
am exporting this image i am able to export it in the same format.

Regards,
Abhishek
 
S

Shyam Pillai

No, PPT does it's own bit of conversion on certain file types once it is
embedded. You cannot do it with VBA. You can parse the information from the
html though.
 
A

Abhishek

Abhishek SignatureAbhishek Bagga Intellimind Systems Pvt. Ltd.
www.sikhya.com (+919815005578
Shyam Pillai said:
No, PPT does it's own bit of conversion on certain file types once it is
embedded. You cannot do it with VBA. You can parse the information from the
html though.
Howz that possible.
Where is the info stored in HTML ?

Abhishek
 
S

Shyam Pillai

Press Alt+Shift+F11 to launch the script editor. Look thru the html that is
generated for the relevant information. Once you know what to look for you
can pull the entire html into a string variable by using the HTML Project
object associated with the presentation and then parse it.

This is a hack which works on 2000+ versions and requires installation of
the Microsoft Script editor.
' ----- Beginning Of Code -----
Option Explicit
Sub Test()
Dim sExt As String
Dim oShp As Shape
Set oShp = ActiveWindow.Selection.ShapeRange(1)
sExt = GetImageExtension(oShp)
MsgBox sExt
End Sub

Function GetImageExtension(oCheckCopy As Object)
On Error GoTo ExitImageExtensionError
Dim oTmpPPT As Object
Dim sHTMLString As String
Dim sBuff As String
oCheckCopy.Copy
Set oTmpPPT = Presentations.Add(False)
With oTmpPPT.Slides.Add(1, ppLayoutBlank)
.Shapes.Paste
End With
sHTMLString = oTmpPPT.HTMLProject.HTMLProjectItems("Slide1").Text
If InStr(1, sHTMLString, "<v:imagedata src=" & Chr(34)) <> 0 Then
sBuff = Mid(sHTMLString, _
InStr(1, sHTMLString, "v:imagedata src=" & Chr(34)) _
+ Len("v:imagedata src=") + 1)
sBuff = Left(sBuff, InStr(1, sBuff, Chr(34)) - 1)
sBuff = Mid(sBuff, InStrRev(sBuff, ".") + 1)
End If
ExitImageExtensionError:
GetImageExtension = sBuff
oTmpPPT.Close
Set oTmpPPT = Nothing
End Function
' ----- End Of Code -----
--
Regards,
Shyam Pillai
Toolbox: http://skp.mvps.org/toolbox
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top