gruntingmonkey
Active Member
- Joined
- Mar 6, 2008
- Messages
- 444
- Office Version
- 365
- Platform
- Windows
I have some code which is opening up a file directory from Excel but I have a couple of issues.
Primarily it debugs when the file is being set (Bolded below). I get a type mismatch and I cant figure it out why!
Further to that, and this isnt important really, but is there a way of limiting results to word files, ie excel, PDFs etc dont show in the directory to be choosen?
Any help would be appreciated!
Primarily it debugs when the file is being set (Bolded below). I get a type mismatch and I cant figure it out why!
Further to that, and this isnt important really, but is there a way of limiting results to word files, ie excel, PDFs etc dont show in the directory to be choosen?
Code:
Sub SelectProposalFromDirectory()
Dim SummaryWB As Documents
Dim vrtSelectedItem As Variant
Dim UserNm As String
UserNm = (Environ$("Username"))
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "C:\Users\" & UserNm & "\Workplace Name\Sales - Documents\Proposals\"
.AllowMultiSelect = False
.Show
For Each vrtSelectedItem In .SelectedItems
[B] Set SummaryWB = Documents.Open(vrtSelectedItem)[/B]
Next
End With
If SummaryWB Is Nothing Then Exit Sub
End Sub
Any help would be appreciated!