We help IT Professionals succeed at work.

Templates Moved To Different Server - Now documents open really slow

Medium Priority
575 Views
Last Modified: 2012-05-06
Hi,

Heres what we used:

Server1 - \\server1\templates\jobs\etc.....

Each time users wanted to create a job document they used one of the templates in a folder like above. All works fine and well. Documents always open fast.

Everything moved to Server2

Server2 - \\server2\templates\jobs\etc....

Now every document that they open that was created with a template on the old server opens extremely slow. From what we can gather it must be timining out trying to look for the original templates on the old server.
New documents or documents made from the templates in the new location are fast.

Is there a utility or program to update this metadata that must be embedded in the documents themselves?

I know I could fool office with a modified DNS entry, but thats a bandaid, I want a fix.

Thanks!
Comment
Watch Question

Retired
CERTIFIED EXPERT
Top Expert 2012
Commented:
You would have to open each document and change the path for the attached template.

This would be very tedious in the current circumstances. I suggest that you reinstate the original template server to speed up the document opening. Then the macro in the snippet can be run. It searches the given folder and subfolders for documents, opens it, checks the server and and changes it to the new server.

Call it with:
FindFiles "C:\MyFolder", "*.doc"
Sub FindFiles(strFolder As String, strFilePattern As String)
    Dim strFileName As String
    Dim strFolders() As String
    Dim iFolderCount As Integer
    Dim i As Integer
    Dim wdDoc As Word.Document
   
    'collect child folders
    strFileName = Dir$(strFolder & "\", vbDirectory)
    Do Until strFileName = ""
        If (GetAttr(strFolder & "\" & strFileName) And vbDirectory) = vbDirectory Then
            If Left$(strFileName, 1) <> "." Then
                ReDim Preserve strFolders(iFolderCount)
                strFolders(iFolderCount) = strFolder & "\" & strFileName
                iFolderCount = iFolderCount + 1
            End If
        End If
        strFileName = Dir$()
    Loop
   
    'process files in current folder
    strFileName = Dir$(strFolder & "\" & strFilePattern)
    Do Until strFileName = ""
            DoEvents
            Set wdDoc = Documents.Open(strFolder & "\" & strFileName)
            If wdDoc.AttachedTemplate.Path = "\\Oldserver\templates\" Then
                wdDoc.AttachedTemplate = "\\NewServer\templates\" & wdDoc.AttachedTemplate.Name
                wdDoc.Close wdSaveChanges
            Else
                wdDoc.Close wdDoNotSaveChanges
            End If
        strFileName = Dir$()
    Loop
   
    'look through child folders
    For i = 0 To iFolderCount - 1
        FindFiles strFolders(i), strFilePattern
    Next i
End Sub

Open in new window

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Commented:
OK. I have done some editing of my code and it's now as shown below.

Questions is on what line should I put the code to skip if the password is wrong?

Also does the code look correct? I am really feeling my way in the dark here. Coding is not my skill but I am trying.
Sub FindFiles(strFolder As String, strFilePattern As String)
    Dim strFileName As String
    Dim strFolders() As String
    Dim iFolderCount As Integer
    Dim i As Integer
    Dim strFilePath As String
    Dim strPath As String
    Dim intCounter As Integer
    Dim OldServer As String
    Dim objDoc As Document
    Dim objTemplate As Template
    Dim dlgTemplate As Dialog
    Dim nServer As Integer
 
 'collect child folders
    strFileName = Dir$(strFolder & "\", vbDirectory)
    Do Until strFileName = ""
        If (GetAttr(strFolder & "\" & strFileName) And vbDirectory) = vbDirectory Then
            If Left$(strFileName, 1) <> "." Then
                ReDim Preserve strFolders(iFolderCount)
                strFolders(iFolderCount) = strFolder & "\" & strFileName
                iFolderCount = iFolderCount + 1
            End If
        End If
        strFileName = Dir$()
    Loop
 
    'hardcode the name of the old server.
    
    OldServer = ""
    nServer = Len(OldServer)
    strFilePath = InputBox("What is the folder location that you want to use?")
 
    If Right(strFilePath, 1) <> "\" Then strFilePath = strFilePath & "\"
 
     strFileName = Dir(strFilePath & "*.doc")
 
     Do While strFileName <> ""
 
     Set objDoc = Documents.Open(strFilePath & strFileName)
 
     Set objTemplate = objDoc.AttachedTemplate
 
     Set dlgTemplate = Dialogs(wdDialogToolsTemplates)
 
     strPath = dlgTemplate.Template
 
   
 
     If LCase(Left(strPath, nServer)) = LCase(OldServer) Then
 
     objDoc.AttachedTemplate = NormalTemplate
 
    End If
 
 
 
    strFileName = Dir()
    objDoc.Save
    objDoc.Close
 
    Loop
 
 
 
    Set objDoc = Nothing
    Set objTemplate = Nothing
    Set dlgTemplate = Nothing
 
 
 
End Sub

Open in new window

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.