Powerpoint VBA slide show Open file

M

mitja

Hi,

I created this VBA script that enables a presenter to show names in
powerpoint text boxes that are read from an Excel file.
We use it for graduations, showing names of graduates that have to come up
to receive their "award".
Everything works Ok, I just want the presenter to choose an Excel file
before the presentation using File open dialog box.

This way works fine, but no dialog box:
Sub Postavi()
Set xlApp = CreateObject("excel.application")
xlApp.Workbooks.Open ("C:\graduates.xlsx")
icnt = 1
MsgBox "OK"
End If

This should be working with dialog box, but it is not. I tried many other
way, but none works. Is it at all possible to open a dialog box when showing
presentation.

Sub Postavi()

Dim fd As FileDialog
Dim strFile As String
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
..InitialView = msoFileDialogViewList
..AllowMultiSelect = False
..Title = "Please browse for your file"
..Filters.Clear
..Filters.Add "presentations", "*.xls,*.xlsx"
If .Show = -1 Then
strFile = .SelectedItems(1)
Set xlApp = CreateObject("excel.application")
xlApp.Workbooks.Open strFile
icnt = 1
MsgBox "OK"
End If
 

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