Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 540
  • Last Modified:

Templates Moved To Different Server - Now documents open really slow

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!
0
borgmember
Asked:
borgmember
1 Solution
 
GrahamSkanRetiredCommented:
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

0
 
r_gibsonCommented:
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

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now