Thread: [Solved] Opening/Saving dialogue box
View Single Post
 
Old 08-03-2011, 02:01 AM
ACA ACA is offline Windows 7 Office 2007
Advanced Beginner
 
Join Date: Aug 2010
Posts: 31
ACA is on a distinguished road
Default

Solution for opening files.
I’ve found some code, originally for filtering files, that does open them.
After pruning off several lines not needed for just one file, I am left with the macro below, that works O.K.

Now, I don’t need the “For Next” loop, as I am opening just one file each time I run the macro. But the line in the middle, by itself, is not accepted; it must be altered in some way that I don’t know.
Any help with just that, please? Thanks a lot.
ACA

Code:
 
Sub Macro1()
'
' Macro1 Macro
 
    Dim fd As FileDialog
    Set fd = Application.FileDialog(msoFileDialogFilePicker)
 
    Dim vrtSelectedItem As Variant
    fd.Filters.Clear
        If fd.Show = True Then
 
            For Each vrtSelectedItem In fd.SelectedItems
            Documents.Open FileName:=vrtSelectedItem   ‘How must this line be altered so that it'll work by itself, without the loop?.
            Next vrtSelectedItem
 
        End If
End Sub
Reply With Quote