Get Open File Dialog Box in Windows 7...old code broke
|
I wrote this code a while back and it's been working beautifully until I switched to Windows 7. This is just part of the code but it's the part that's broken right now and I'm getting an error message. I need to present an open file dialog box and allow the user to select the appropriate Excel file. Here's the current code:
Code:
Sub Open_File_Dialog
Dim objDialog, intResult
'Displays an open file dialog box and opens file selected
Set objDialog = CreateObject("UserAccounts.CommonDialog")
objDialog.Filter = "Excel Files (.xls)|*.xls"
objDialog.FilterIndex = 1
objDialog.InitialDir = "H:\Account Detail\"
intResult = objDialog.ShowOpen
If intResult = 0 Then
Dim msg
msg = "Must Select a File"
MsgBox msg, vbinformation + vbcritical
Set objDialog = Nothing
Wscript.Quit
Else
ExcelFile = objDialog.FileName
End If
Set objDialog = Nothing
End Sub
I'm getting an error message on this line:
Code:
Set objDialog = CreateObject("UserAccounts.CommonDialog")
How would I update this to do the same thing in Windows 7? Thanks so much for the help. It's been a while since I've done this stuff so I'm not up to date at all.
|
__________________
There are some things that we will never know
And we will never know that we don't know them.
|