Link to home
Start Free TrialLog in
Avatar of KarlSolid
KarlSolid

asked on

Document Template Path to server map that no longer exists.

I have a user who was moved over to Office 2010 from Office 2003. At the same time they had their servers replaced and now experience very slow document opening time, as Word is searching for a >DOT path that does not exist any longer. Is there a way to remove these template references in masse without opening every document individually? I had thought about DNS to the old path, but that seems a bit messy.
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

If you could temporarily re-instate a server with the old name and share, you could get any user to run some code like this.

It will look at all the documents in the given folder and its subfolders, open each documents and chagethe path for the attached template. Note that the root documents folder and the server share paths are hard-coded and need to be adapted to the situation.
Sub ChangeTemplates()
  FindFiles "C:\DocumentFolders", "*.doc*" '<---- edit this path
End Sub

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 doc As 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 doc = Documents.Open(strFolder & "\" & strFileName)
            If doc.AttachedTemplate.Path = "\\Oldserver\templates\" Then '<---- edit this path
                doc.AttachedTemplate = "\\NewServer\templates\" & doc.AttachedTemplate.Name '<---- edit this path
                doc.Close wdSaveChanges
            Else
                doc.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

Avatar of KarlSolid
KarlSolid

ASKER

Ok my questions would be:

How do I address the files on the server shares, these are all stored on several file shares with mapped network drives. My concern is that some of these will not be accessed by a local user untill needed. Is there a way to run the script server side to change properties?
I think that it would work on any system that has Word installed and can access the document files.
Should I build this in Visual Basic
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You should delete the virtual drive from the machine
Open My computer, find the mapped drive and remove/disconnect it
When an Office application is launched, if the templates used were in the mapped drive, the application will ask to replace it or will revert to the default.
Worked Like a charm