Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

XL: Workbooks Containing User Forms Take Excessively Long Time to Save Across WAN Connections


View products that this article applies to.

Symptoms

When you save Excel workbooks that contain user forms, it typically takes about one minute to save to the local computer or within the local area network (LAN). When you save the same workbooks over a wide area network (WAN), it can take an excessive amount of time.

↑ Back to the top


Cause

When Excel saves a user form, it writes out each control separately, and waits for an acknowledgement from the network before proceeding to the next control. The amount of time it takes to save is relative to the number of controls and user forms, and the network and remote drive latency.

↑ Back to the top


Workaround

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs.
If you have limited programming experience, you may want to contact a Microsoft Certified Partner or Microsoft Advisory Services. For more information, visit these Microsoft Web sites:

Microsoft Certified Partners - https://partner.microsoft.com/global/30000104

Microsoft Advisory Services - http://support.microsoft.com/gp/advisoryservice

For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS To work around this problem, the following Microsoft Visual Basic for Applications (VBA) macros copy the document to the local drive, and then share that local copy back to the WAN.

To implement the workaround, follow these steps:
  1. Start Excel and open the VBA editor by pressing ALT+F11.
  2. On the Insert menu, click Module.
  3. Type the following code in the new module:
    Option Explicit
    Private Const TEMPFILE As String = "c:\dlocal.xls" 
    'Note, ensure the file path is valid.
    
    Private Const TEMPFILE2 As String = "c:\dlocal2.xls" 
    'Note, ensure the file path is valid.
    
    Private strOriginalName As String
    Public bSaving As Boolean
    
    Public Sub SaveLocalThenCopy()
        Dim wbk As Workbook, wbk2 As Workbook
        Set wbk = ThisWorkbook
        If UCase(ThisWorkbook.FullName) <> UCase(TEMPFILE) Then strOriginalName = ThisWorkbook.FullName
        If Dir(TEMPFILE) <> "" Then Kill TEMPFILE
        If Dir(TEMPFILE2) <> "" Then Kill TEMPFILE2
        ThisWorkbook.SaveAs TEMPFILE
        ThisWorkbook.SaveAs TEMPFILE2
        FileCopy TEMPFILE, strOriginalName
        Set wbk2 = Workbooks.Open(strOriginalName)
        bSaving = False
        wbk.Close False
    End Sub
    						
    The following steps add code to the workbook's BeforeSave event to run the workaround above.
  4. In the VBAProject window, double-click the ThisWorkbook icon to open the Code window.
  5. At the top of this new Code window, there are two drop-down lists. In the Object (left) list, click Workbook; in the Procedure (right) list, click BeforeSave.
  6. Type the following code in the Code window:
    Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
        If bSaving Then Cancel = False: Exit Sub
        Dim iAns As Integer
        iAns = MsgBox("Do you wish to Save As...?", vbYesNoCancel, "Save")
        Select Case iAns
            Case vbYes
                Cancel = True
                bSaving = True
                Application.Dialogs(xlDialogSaveAs).Show
                bSaving = False
                Exit Sub
            Case vbNo
                'Do normal - local save.
            Case vbCancel
                Cancel = True
                Exit Sub
        End Select
        bSaving = True
        Cancel = True
        Application.OnTime Now + TimeValue("00:00:01"), "SaveLocalThenCopy"
    End Sub
    					
Now, when you click Save As, Excel prompts you to choose either the default Excel Save As dialog box (click Yes), or to use the workaround above to save the document (click No).

↑ Back to the top


Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.

↑ Back to the top


Keywords: KB254733, kbprb, kbfix, kbdtacode

↑ Back to the top

Article Info
Article ID : 254733
Revision : 7
Created on : 11/23/2006
Published on : 11/23/2006
Exists online : False
Views : 317