Hello, I hope i can get some help from people whom i regard as super smart.
The code below (that i have managed to get from others) finds the username and computer name so that other users would be able to use the same code on their computers.
I had hoped that the code would also open the filename "Element List (whatever the user had named the file).xlxs"
(The filename will ALWAYS begin with"Element List".) if that cannot be done, then if the directory could open for the user to choose the file manually.
the code below opens the directory to Documents, leaving the user to stumble along the path to find the file.
Your help will be greatly appreciated.
many thanks in advance
Andy
Dim wkb2 As Workbook
Dim UsersName As String, strFileName As String
UsersName = Environ("USERNAME")
strFileName = "C:\Users" & UsersName & _
"\Desktop\Excalibur Winner\ExcaliburProPlus\_ExcaliburDataConfig\Element list - Export.xlsx"
If Not Dir(strFileName, vbDirectory) = vbNullString Then
Set wkb2 = Workbooks.Open(strFileName, False, False)
Else
MsgBox strFileName & Chr(10) & Chr(10) & Space(Len(strFileName) / 2) & "File Not Found", 48, "Not Found"
End If
FilterIndx = IIf(Val(Application.Version) < 12, 1, 2)
FileFilter = "Excel 2003 (*.xls),*.xls," & _
"Excel 2007 > (*.xlsx),*.xlsx," & _
"All Excel Files (*.xl*),*.xl*," & _
"All Files (*.*),*.*"
GetFileName = Application.GetOpenFilename(FileFilter, FilterIndx, "Select One File To Open")
If VarType(GetFileName) = vbBoolean Then GetFileName = CVErr(10)
The code below (that i have managed to get from others) finds the username and computer name so that other users would be able to use the same code on their computers.
I had hoped that the code would also open the filename "Element List (whatever the user had named the file).xlxs"
(The filename will ALWAYS begin with"Element List".) if that cannot be done, then if the directory could open for the user to choose the file manually.
the code below opens the directory to Documents, leaving the user to stumble along the path to find the file.
Your help will be greatly appreciated.
many thanks in advance
Andy
Dim wkb2 As Workbook
Dim UsersName As String, strFileName As String
UsersName = Environ("USERNAME")
strFileName = "C:\Users" & UsersName & _
"\Desktop\Excalibur Winner\ExcaliburProPlus\_ExcaliburDataConfig\Element list - Export.xlsx"
If Not Dir(strFileName, vbDirectory) = vbNullString Then
Set wkb2 = Workbooks.Open(strFileName, False, False)
Else
MsgBox strFileName & Chr(10) & Chr(10) & Space(Len(strFileName) / 2) & "File Not Found", 48, "Not Found"
End If
FilterIndx = IIf(Val(Application.Version) < 12, 1, 2)
FileFilter = "Excel 2003 (*.xls),*.xls," & _
"Excel 2007 > (*.xlsx),*.xlsx," & _
"All Excel Files (*.xl*),*.xl*," & _
"All Files (*.*),*.*"
GetFileName = Application.GetOpenFilename(FileFilter, FilterIndx, "Select One File To Open")
If VarType(GetFileName) = vbBoolean Then GetFileName = CVErr(10)