• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 630
  • Last Modified:

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.
0
KarlSolid
Asked:
KarlSolid
  • 3
  • 3
1 Solution
 
GrahamSkanRetiredCommented:
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

0
 
KarlSolidAuthor Commented:
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?
0
 
GrahamSkanRetiredCommented:
I think that it would work on any system that has Word installed and can access the document files.
0
The Firewall Audit Checklist

Preparing for a firewall audit today is almost impossible.
AlgoSec, together with some of the largest global organizations and auditors, has created a checklist to follow when preparing for your firewall audit. Simplify risk mitigation while staying compliant all of the time!

 
KarlSolidAuthor Commented:
Should I build this in Visual Basic
0
 
GrahamSkanRetiredCommented:
Yes. It is for Visual Basic for Applications, so you don't need a separate version of Visual Basic. It is written to run as a Word macro, so it needs to be put into a code module in a Word template (Normal will do).

To get to the VBA editor in any Office application, hit Alt+F11. In Word, you will see in the top left-hand pane that you there is a Project called Normal. If there are expand it with the +  sign. If there is no 'folder' called Modules, add a module from the Insert menu. Select and open the new or an existing module by double-clicking. Paste the code into the right-hand pane. Edit the lines to suit - you might want to work on a small test folder first. Place the cursor in the 'ChangeTemplates' sub and press F5 (run).

If you get an error that you can't fix, tell us what the error message is and which line is highlighted in yellow.
0
 
xtermieCommented:
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.
0
 
KarlSolidAuthor Commented:
Worked Like a charm
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

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