Results 1 to 2 of 2

Unexpected crash after macro execution

Threaded View

  1. #1
    Registered User
    Join Date
    08-09-2012
    Location
    Romania
    MS-Off Ver
    Excel 2010
    Posts
    1

    Unexpected crash after macro execution

    Hi,
    I have a macro which i need to run 10 times for different paths. The macros are the same excepting the "path_usr" and "file_usr". The macros needs to open another excel document, and replace the PROJECTS sheet from that document with the same named sheet form the first document. I do it in this way:

    Sub copysheet_usr()
    
    
    Dim w As Workbook
    Dim path, page As String
    
    
    page = "PROJECTS"
    path = "\\192.168.0.6\path_usr\file_usr.xls"
    Set w = Workbooks.Open(path)
    w.Activate
    For Each n In ActiveWorkbook.Names
    n.Delete
    Next n
    Application.DisplayAlerts = False
    w.Worksheets(page).Delete
    Application.DisplayAlerts = True
    Windows("file_usr.xls").Activate
    Worksheets(page).Select
    Worksheets(page).Copy Before:=w.Worksheets(1)
    Application.DisplayAlerts = False
    w.Close True
    Application.DisplayAlerts = True
    
    End Sub
    This macro works without problems one time, but when i try to run it for the second user, it gives me the "Microsoft Excel has encoutered a problem and needs to close" error on the "Set w = Workbooks.Open(path)" step. Also if i simply close Microsoft Excel after the first macro execution i get the same error.
    I can succesfully run each macro individually, but i need to restart Excel after every macro.
    I have Microsoft Excel 2010 installed, on my Windows XP SP3, with no active add-ins in Excel.
    It is very strange that sometimes i can run 2 or 3 macros before the crash, and if all the files are on the local computer, not on the network, it is no error at all.
    If anyone can help me thanks in advance.
    Last edited by arlu1201; 09-05-2012 at 06:04 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1