Change path to template when upgrading from Word 97 to 2003

S

staeri

I have a few questions regarding a upgrade from Word 97 to 2003.

Today I have many Word 97-doc files in catalog S:\W97. All the files
are based on templates in the same catalog.
I'm going to upgrade from Office 97 to Office 2003 and there are some
VBA related errors that occurs when opening the doc files. The VBA
code is placed only in the template, not in the doc file.

1. In general, will it be enough to fix the VBA errors in the template
or do I have to open each doc file that is based on the template and
make any change there?

2. All upgraded files and templates will be placed in a new catalog
called S:\W2003. I need to change the link to the template from S:\W97
to S:\W2003 automatically for all files in the catalog. How can that
be done?

3. In the doc files I need to change the path to an Access db from S:
\DB97 to S:\DB2003 automatically for all files in the catalog. How can
that be done?

I'm very grateful for help!

// SE
 
G

Graham Mayor

I assume that some or all of the documents in W97 are mailmerge documents
and that they are attached to data sources in the DB97 folder?
That being the case and provided there is nothing else about the documents
that you haven't mentioned, then documents that are based on the normal
template will be unaffected by the move with relation to the attached
template. Word always knows where its normal template is. Documents based on
other templates will need to be updated to reflect the new location of the
documents and the data sources in either case will require updating to
reflect their new locations.

The following macro does that. You may need to modify what happens when your
documents are opened, but the basic code is included to open each of the
documents in a selected folder, attach the template and if necessary attach
the data source from their new locations as you have described them then
saves the documents to the W2003 folder. The files in the W97 folder should
be unaffected. Obviously I can't test it in your environment but it appears
to work and I have not included any error trapping to cover what you haven't
told us.

I wonder to what extent any of this is necessary? Why not continue to work
with the 97 folder structure and just modify those macros that require small
changes?

Dim strFile As String
Dim strPath As String
Dim strTempl As String
Dim sData As String
Dim oDoc As Document
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)

With fDialog
.Title = "Select Folder containing the documents to be modifed and click
OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User"
Exit Sub
End If
strPath = fDialog.SelectedItems.Item(1)
If Right(strPath, 1) <> "\" Then strPath = strPath + "\"
End With

If Documents.Count > 0 Then
Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
strFile = Dir$(strPath & "*.do?")

While strFile <> ""
Set oDoc = Documents.Open(strPath & strFile)
strTempl = ActiveDocument.AttachedTemplate.name
With oDoc
.UpdateStylesOnOpen = False
.AttachedTemplate = "S:\W2003\" & strTempl
If .MailMerge.MainDocumentType <> wdNotAMergeDocument Then
sData = .MailMerge.DataSource.name
If Left(sData, 7) = "S:\DB97" Then
.MailMerge.OpenDataSource name:="S:\DB2003" & _
Right(sData, Len(sData) - 7), _
ConfirmConversions:=False
End If
End If
.SaveAs "S:\W2003\" & .name
.Close
End With
strFile = Dir$()
Wend


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
S

staeri

I assume that some or all of the documents in W97 are mailmerge documents
and that they are attached to data sources in the DB97 folder?
That being the case and provided there is nothing else about the documents
that you haven't mentioned, then documents that are based on the normal
template will be unaffected by the move with relation to the attached
template.Wordalways knows where its normal template is. Documents based on
other templates will need to be updated to reflect the new location of the
documents and the data sources in either case will require updating to
reflect their new locations.

The following macro does that. You may need to modify what happens when your
documents are opened, but the basic code is included to open each of the
documents in a selected folder, attach the template and if necessary attach
the data source from their new locations as you have described them then
saves the documents to the W2003 folder. The files in the W97 folder should
be unaffected. Obviously I can't test it in your environment but it appears
to work and I have not included any error trapping to cover what you haven't
told us.

I wonder to what extent any of this is necessary? Why not continue to work
with the 97 folder structure and just modify those macros that require small
changes?

Dim strFile As String
Dim strPath As String
Dim strTempl As String
Dim sData As String
Dim oDoc As Document
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)

With fDialog
    .Title = "Select Folder containing the documents to be modifed and click
OK"
    .AllowMultiSelect = False
    .InitialView = msoFileDialogViewList
    If .Show <> -1 Then
        MsgBox "Cancelled By User"
        Exit Sub
    End If
    strPath = fDialog.SelectedItems.Item(1)
    If Right(strPath, 1) <> "\" Then strPath = strPath + "\"
End With

If Documents.Count > 0 Then
    Documents.Close SaveChanges:=wdPromptToSaveChanges
End If
strFile = Dir$(strPath & "*.do?")

While strFile <> ""
    Set oDoc = Documents.Open(strPath & strFile)
    strTempl = ActiveDocument.AttachedTemplate.name
    With oDoc
        .UpdateStylesOnOpen = False
        .AttachedTemplate = "S:\W2003\" & strTempl
        If .MailMerge.MainDocumentType <> wdNotAMergeDocument Then
            sData = .MailMerge.DataSource.name
            If Left(sData, 7) = "S:\DB97" Then
                .MailMerge.OpenDataSource name:="S:\DB2003" & _
                Right(sData, Len(sData) - 7), _
                ConfirmConversions:=False
            End If
        End If
        .SaveAs "S:\W2003\" & .name
        .Close
    End With
    strFile = Dir$()
Wend

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor -  WordMVP

My web sitewww.gmayor.comWordMVP web sitehttp://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>











- Visa citerad text -

Graham,

Thank you very much for the detailed answer!

Best regards,

SE
 
S

staeri

Graham,

Thank you very much for the detailed answer!

Best regards,

SE- Dölj citerad text -

- Visa citerad text -

One more question:

Some people say that the code in the dot file is embedded in the doc
file so that a change in a dot file won't affect an existing doc file
created from the dot file, only new files that are created. Some
people say that that the code is not embedded in the doc file so that
a change in the dot file will affect an existing doc file linked to
the dot file. Which is correct?

// SE
 
G

Graham Mayor

On 19 Dec, 08:59, (e-mail address removed) wrote:
One more question:

Some people say that the code in the dot file is embedded in the doc
file so that a change in a dot file won't affect an existing doc file
created from the dot file, only new files that are created. Some
people say that that the code is not embedded in the doc file so that
a change in the dot file will affect an existing doc file linked to
the dot file. Which is correct?

// SE
While it is certainly possible to store code in a document, code is not
transferred to a new document based on a template containing the code. It
remains in the template.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top