Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel VBA fails when opened from network drive

Status
Not open for further replies.

w0374

Technical User
Apr 4, 2008
3
GB
Hi, I have a spreadsheet that runs a macro to search the current worksheet for the text entered in a text box. The code runs OK when the spreadsheet is opened from a local drive but fails unexpectedly when the spreadsheet is opened from a network drive. Any ideas what maybe causing this? Thanks

Code:
Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
If KeyCode = 13 Then
    Dim c As Range
    Dim wb As String
    wb = ActiveWorkbook.Name
    With Workbooks(wb).ActiveSheet.Cells
        Set c = .Find(What:=TextBox1.Value, LookAt:=xlPart)
        If c Is Nothing Then
            r = MsgBox("Search text not found", vbExclamation, "Find")
            TextBox1.Activate
            Exit Sub
        End If
        firstAddress = c.Address
        Do
            If Not c Is Nothing Then
                If Not (c.EntireColumn.Hidden = True Or c.EntireRow.Hidden = True) Then
                    Workbooks(wb).ActiveSheet.Cells(c.Row, c.Column).Select
                    r = MsgBox("Match found in cell " & c.Address & vbCrLf & "Continue search?", vbQuestion + vbYesNo, "Find")
                    If r = vbNo Then
                        Exit Sub
                    End If
                End If
                Set c = .Find(What:=TextBox1.Value, After:=c)
            End If
        Loop While Not c Is Nothing And c.Address <> firstAddress
        r = MsgBox("No more matches found", vbInformation, "Find")
    End With
End If
End Sub
 
I know if office 2007 you have change your trusted sites to include files from a network. You may want to check out to make sure your computer is allowing the vba to run at all.
Check macro security

If the vba starts to run (then macro security is not the issue) and then fails where does it fail what error are you getting? what is it not doing?

ck1999
 
VBA does start to run so I do not believe this is a macro security issue - for information it is set to medium

The VBA code runs until it reaches the 4th from last line
r = MsgBox("No more matches found", vbInformation, "Find")
It performs the MSGBOX and then Excel crashes with a popup window saying 'Microsoft Excel has encountered a problem and needs to close'.

I am running Excel 2002 SP3 (10.0.6501.0), the failing module is fm20.dll @ 00010b06

Please note this error only occurs f you open the spreadsheet from a network drive, no error if you open from a local drive.

Thanks


 
The error does not occur when the spreadsheet is opened from a network drive using Excel 2003. Anyone know if there have been a bug fixes in the latest Excel 2002 SP3 hotfix package for Excel crashing when spreadsheets ae opended from a network drive?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top