 | Senior Member with 151 posts. | | Join Date: Apr 2007 Location: Seattle, WA Experience: Flash Guru - VBA.... still learning | | Solved: Hi to all my old friends, and intro to any new ones!!!! If you dont already know me....
My name is Red and have been working with VBA for a couple years, with mainly the PPT and word object models...
If you have any questions about it please drop me a line! I have been away from this forum for a bit but am back hopfully for good. My distractions have been around learning Lectora and a few other eLearning apps, but have come full circle and am back to some of my original ideas about making an Auto Suite of my own and basing my new company around some new products I have been working on for about 5 years now....!
with that said... let's get to it!
I have two questions I am looking to discuss over the next couple weeks....
1. Does anybody know how to grab a graphic off of a PPT slide and copy it to a selected folder?
2. Does anybody know if I can set up delimited areas in the notes section of PPT and copy/paste them into a bookmarked area of a word doc??? I already have the code working to copy/paste text from the slide to a .doc..... needing help with the delimited notes part....
Glad to be back in the mix!
Red | | Moderator with 18,667 posts. | | Join Date: Oct 2003 Location: Surrey, UK Experience: Intermediate | | 1) i would click on it - copy and then paste into paint and save | | Senior Member with 151 posts. | | Join Date: Apr 2007 Location: Seattle, WA Experience: Flash Guru - VBA.... still learning | | Thanks for the post... I am looking for a automated VBA solution, but thanks for the post! | | Distinguished Member with 9,339 posts. | | Join Date: Mar 2005 Location: UK Experience: An old Basic Programmer | | Can you post an Example of what you want to do (in both cases), not that I know much PPT VBA. | | Senior Member with 131 posts. | | Join Date: Nov 2007 Experience: Advanced | | Red
You will need to use the Shape.Export(path,format,width,height) method to export as a picture format
It's a hidden method so you will need to open the object browser > Right click > Show Hidden Members | | Distinguished Member with 4,589 posts. | | Join Date: Nov 1999 Experience: Advanced | | Also you might try "Save As" and select a image type, and then the wizard may ask if you for the current or all slides.
It does for me in PowerPoint 2003 and 2007! | | Senior Member with 151 posts. | | Join Date: Apr 2007 Location: Seattle, WA Experience: Flash Guru - VBA.... still learning | | Code... Sub ExportSlideGraphics()
Dim ExportPath As String ' drive:\path to export to
Dim oSlide As Slide
ExportPath = "C:\Graphics"
Set oSlide = ActivePresentation.Slides 'getting an error here....
With oSlide
.Export ExportPath & "Slide" & CStr(.SlideIndex) & ".JPG", "JPG"
End With
End Sub | | Senior Member with 151 posts. | | Join Date: Apr 2007 Location: Seattle, WA Experience: Flash Guru - VBA.... still learning | | ... this is the code I am playing with to save slide images to path folder - above |||| | | Senior Member with 131 posts. | | Join Date: Nov 2007 Experience: Advanced | | Red
That will (if you set oslide properly) export the whole slide as a jpg. Is that what you need? | | Senior Member with 151 posts. | | Join Date: Apr 2007 Location: Seattle, WA Experience: Flash Guru - VBA.... still learning |
02-Nov-2009, 01:56 PM
#10 | no no - but i do see what you are saying with this:
Sub Export(PathName As String, Filter As PpShapeFormat, [ScaleWidth As Long], [ScaleHeight As Long], [ExportMode As PpExportMode = ppRelativeToSlide])
Const ppShapeFormatPNG = 2
End Sub
just need help filling it out to match the above path... | | Senior Member with 151 posts. | | Join Date: Apr 2007 Location: Seattle, WA Experience: Flash Guru - VBA.... still learning |
02-Nov-2009, 02:58 PM
#11 | i HAVE MADE A NEW THREAD TO HANDLE THE QUESTION #2 PLEASE USE IT TO ANSWER... | | Senior Member with 151 posts. | | Join Date: Apr 2007 Location: Seattle, WA Experience: Flash Guru - VBA.... still learning |
02-Nov-2009, 04:25 PM
#12 | Gezz I havent written VBA in a year or so... I am rusty but this is close to what I want...
Sub ExportSlideGraphics()
Dim x As Long
Dim y As Long
Dim i As Integer
Dim objText As Object
i = 1
For x = 1 To ActivePresentation.Slides.Count
For y = 1 To ActivePresentation.Slides(x).Shapes.Count
If ActivePresentation.Slides(x).Shapes(y).Type = Shapes Then
Call ActiveWindow.Selection.ShapeRange(1).Export( _
"C:\Graphics\filename" & x & ".jpg", _
ppShapeFormatJPG)
End If
Next x
Next y
End Sub | | Distinguished Member with 6,294 posts. | | Join Date: Oct 2004 Location: Southwest Iowa.... Experience: Currently stupid... |
02-Nov-2009, 05:38 PM
#13 | All, this is something I found online (forget where, sorry someone) that I sent to Red in a private message: Code: Call ActiveWindow.Selection.ShapeRange(1).Export( _
"C:\Workarea\filename.gif", _
ppShapeFormatGIF)
The same page says:
"Use .ShapeRange.Export instead of .ShapeRange(1).Export to export the entire current selection to a graphics file. There will be a white or black background between shapes, regardless of what your presentation's background might be."
And, of course, you can choose another format (.jpg, .png) rather than .gif.
I think that code should be easier than looping to the Next one.[
__________________ Iowa? I could have sworn this was heaven.
Well, I think I can answer this question most successfully in mime. My theme song... | Affero - rate me! | | Senior Member with 151 posts. | | Join Date: Apr 2007 Location: Seattle, WA Experience: Flash Guru - VBA.... still learning |
02-Nov-2009, 09:24 PM
#14 | I think this is pretty close to what I need, but its not outputing any graphic.?!?!? But Im not getting any errors either...
Sub export_pic()
Dim osld As Slide
Dim oshp As Shape
Dim strPath As String
strPath = "C:\Graphics"
For Each osld In ActivePresentation.Slides
For Each oshp In osld.Shapes
If oshp.Type = msoPicture Then
oshp.Export strPath & "Slide " & CStr(osld.SlideIndex) & "Pic.png", ppShapeFormatPNG
End If
Next oshp
Next osld
End Sub | | Senior Member with 151 posts. | | Join Date: Apr 2007 Location: Seattle, WA Experience: Flash Guru - VBA.... still learning |
03-Nov-2009, 01:13 AM
#15 | Sub ExtractImages()
On Error GoTo ErrorExtract
Dim oPres As Presentation
Dim oSldSource As Slide
Dim oShpImg As ShapeRange
Dim oShpSource As Shape
Dim oSld As Slide
Dim oShp As Shape
Dim Ctr As Integer
Dim sPath As String
sPath = "C:\Temp\"
Ctr = 0
For Each oSldSource In ActivePresentation.Slides
For Each oShpSource In oSldSource.Shapes
If oShpSource.Type = msoPicture Then
Set oShp = oShpSource
Set oPres = Presentations.Add(False)
With oPres.PageSetup
.SlideSize = ppSlideSizeCustom
.SlideHeight = oShp.Height
.SlideWidth = oShp.Width
End With
Set oSld = oPres.Slides.Add(1, ppLayoutBlank)
oShp.Copy
Set oShpImg = oSld.Shapes.Paste
With oShpImg
.Left = 0
.Top = 0
End With
Ctr = Ctr + 1
Call oSld.Export(sPath & "Img" & Format(Ctr, "00000") & ".JPG", "JPG")
oPres.Close
End If
Next oShpSource
Next oSldSource
If Ctr = 0 Then
MsgBox "There were no images found in this presentation", _
vbInformation, "Image extraction failed."
End If
Exit Sub
ErrorExtract:
If Err.Number <> 0 Then
MsgBox Err.Description, vbCritical, "Error #" & Err.Number
End If
End Sub | |
Smart Search
| Find your solution! | |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | | |  WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
| You Are Using: |
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 05:11 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd. | |
|