Reputation: 11
Can anybody help me about this issue. I found a script to take snapshot from first page of my PowerPoint. it works when I run the macro in normal view. but when i use the action button (hyperlink it to created macro) and click on it at the slideshow, there is no action. I expect it to take snapshot from my presentation view every time i click the Action button on slide show.. but nothing
this is the script (I do not have any programming knowledge)
Sub SaveCurrentSlideAsJpg()
Dim imagePath As String
Dim slideNum As Integer
imagePath = "C:\JPG\"
slideNum = ActiveWindow.Selection.SlideRange(1).SlideIndex
If Dir(imagePath & ActivePresentation.Name & "_" & slideNum & ".jpg") <> ""
Then
Kill imagePath & ActivePresentation.Name & "_" & slideNum & ".jpg"
End If
ActivePresentation.Slides(slideNum).Export _
FileName:=imagePath & ActivePresentation.Name & "_" & slideNum & ".jpg", _
FilterName:="JPG"
End Sub
Upvotes: 1
Views: 283
Reputation: 49998
If you are referencing the SlideIndex
during a slideshow, you can do it like this:
slideNum = ActivePresentation.SlideShowWindow.View.Slide.SlideIndex
Here's the full code, with some slight modifications:
Sub SaveCurrentSlideAsJpg()
Dim imagePath As String
Dim slideNum As Integer
Dim fullJpgName As String
imagePath = "C:\JPG\"
slideNum = ActivePresentation.SlideShowWindow.View.Slide.SlideIndex
fullJpgName = imagePath & ActivePresentation.Name & "_" & slideNum & ".jpg"
If Dir(fullJpgName) <> "" Then
Kill fullJpgName
End If
ActivePresentation.Slides(slideNum).Export _
FileName:=fullJpgName, FilterName:="JPG"
End Sub
Upvotes: 1