What is the most likely cause for this bit of code to work for one user but not another? It throws a subscript out of range error at the highlighted line when users other than me run it. This issue has vexed me for over 2 weeks now so any assistance is greatly appreciated, in advance. I will gladly suffer any embarrassment if I'm doing something fundamentally wrong.
Code:
Sub MyTestSub()
Dim MyPathFileName As String, MyFileName As String, MyWBName As String, MyContents As String
MyPathFileName = Application.GetOpenFilename("Excel Files (*.xlsx), * .xlsx")
MyFileName = Right(MyPathFileName, Len(MyPathFileName) - InStrRev(MyPathFileName, "\"))
MyWBName = Replace(MyFileName, ".xlsx", "")
Workbooks.Open Filename:=MyPathFileName
[COLOR=#ff0000]Workbooks(MyWBName).Activate[/COLOR]
MyContents = Workbooks(MyWBName).Sheets("Sheet1").Range("B3").Value
MsgBox "Cell B3 contains " + MyContents
End Sub