T
Tony Logan
From Word, I want to be able to display a dialog box prompting users to pick
a PowerPoint file. I want to open the PPT file, save the PPT file as JPGs
(all slides in the PPT), then close the PPT file, revert back to Word, and do
some more stuff in Word.
The PPT file will always be in the folder C:\Work. I'd like to be able to
build a folder for the JPG slides that would be C:\Work\name_of_the_PPT_file,
so users could easily reference the correct folder if they needed to at some
future point.
Below is some code that gets me part of the way there, but I can't figure
out how to get just the name of the PPT file.
I tried using something like this:
PathOnly = WordBasic.FilenameInfo$(.Name, 5)
....but that only works if I display a second dialog box and write more
coding, all of which seems cumbersome for users, plus I want to keep the
coding as streamlined as possible.
Anyone have any ideas how I can extract just the filename of the PPT file
from the variables I have in the code, or do I need to do a major rewrite?
= = = = = = = = =
Sub Insert_PPT_pics()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Dim vrtItem As Variant
Dim ppt1 As Variant
Dim myFile As String
With fd
.AllowMultiSelect = False
.Filters.Add "PowerPoint files", "*.ppt", 1
.FilterIndex = 1
.InitialFileName = "C:\Work"
.InitialView = msoFileDialogViewList
If .Show = -1 Then
For Each vrtItem In .SelectedItems
myFile = vrtItem
Next vrtItem
End If
End With
Set fd = Nothing
Set ppt1 = CreateObject("PowerPoint.Application")
ppt1.Visible = True
ppt1.Presentations.Open (myFile)
ppt1.Activate
' Here is where I want to save the PPT file as JPGs.
' Need to figure out how to get just the name of
' the PPT file rather than the whole path.
ppt1.Quit
' Release object references
Set ppt1 = Nothing
' revert to Word
Selection.HomeKey Unit:=wdStory
' do some stuff in Word
End Sub
a PowerPoint file. I want to open the PPT file, save the PPT file as JPGs
(all slides in the PPT), then close the PPT file, revert back to Word, and do
some more stuff in Word.
The PPT file will always be in the folder C:\Work. I'd like to be able to
build a folder for the JPG slides that would be C:\Work\name_of_the_PPT_file,
so users could easily reference the correct folder if they needed to at some
future point.
Below is some code that gets me part of the way there, but I can't figure
out how to get just the name of the PPT file.
I tried using something like this:
PathOnly = WordBasic.FilenameInfo$(.Name, 5)
....but that only works if I display a second dialog box and write more
coding, all of which seems cumbersome for users, plus I want to keep the
coding as streamlined as possible.
Anyone have any ideas how I can extract just the filename of the PPT file
from the variables I have in the code, or do I need to do a major rewrite?
= = = = = = = = =
Sub Insert_PPT_pics()
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
Dim vrtItem As Variant
Dim ppt1 As Variant
Dim myFile As String
With fd
.AllowMultiSelect = False
.Filters.Add "PowerPoint files", "*.ppt", 1
.FilterIndex = 1
.InitialFileName = "C:\Work"
.InitialView = msoFileDialogViewList
If .Show = -1 Then
For Each vrtItem In .SelectedItems
myFile = vrtItem
Next vrtItem
End If
End With
Set fd = Nothing
Set ppt1 = CreateObject("PowerPoint.Application")
ppt1.Visible = True
ppt1.Presentations.Open (myFile)
ppt1.Activate
' Here is where I want to save the PPT file as JPGs.
' Need to figure out how to get just the name of
' the PPT file rather than the whole path.
ppt1.Quit
' Release object references
Set ppt1 = Nothing
' revert to Word
Selection.HomeKey Unit:=wdStory
' do some stuff in Word
End Sub