Macro to change format from dot to dotx

V

Vivian

Basically I want a generic macro that will change the ActiveDocument from
dot to dotx. I have 1923 documents that need to be changed. Below is the
macro I created but it saves with the current file name. I have tried
wdFieldFileName but it did not work. I am new at this so any help would be
greatly appreciated.

ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument
ChangeFileOpenDirectory "J:\2007\"
ActiveDocument.SaveAs FileName:= _
"CHARGING - Juvenile Summons (TRACTOR FEED).dotx"
 
G

Greg Maxey

See:

http://gregmaxey.mvps.org/Process_Batch_Folder.htm
Basically I want a generic macro that will change the ActiveDocument
from dot to dotx. I have 1923 documents that need to be changed.
Below is the macro I created but it saves with the current file name.
I have tried wdFieldFileName but it did not work. I am new at this so
any help would be greatly appreciated.

ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument
ChangeFileOpenDirectory "J:\2007\"
ActiveDocument.SaveAs FileName:= _
"CHARGING - Juvenile Summons (TRACTOR FEED).dotx"

--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org


McCain/Palin '08 !!!
 
V

Vivian

Hi Greg,
I downloaded the batch process but found it was for doc not dot. Where can I
change the code so it will be dot to dotx? excuse my ignorance.
I also visited your website...thank you for serving our country so well.
Vivian
 
G

Greg Maxey

Vivian,

I didn't test this, but I believe you would open the BatchProcesses template
and in the Function Convert_docs and change:

FileFormat:=wdFormatXMLdocument

to:

FileFormat:=wdFormatXMLtemplate


Thanks.

Hi Greg,
I downloaded the batch process but found it was for doc not dot.
Where can I change the code so it will be dot to dotx? excuse my
ignorance. I also visited your website...thank you for serving our country
so
well. Vivian

--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org


McCain/Palin '08 !!!
 
G

Graham Mayor

Frankly I can't see any good reason to do this. DOT format templates should
work fine in Word 2007 - and in any case DOTM format *may* provide a
functionality closer to the original, but I certainly have no intention of
gratuitously converting my templates. However, something along the lines.

Sub SaveAllAsDOTX()
Dim strFileName As String
Dim strDocName As String
Dim strPath As String
Dim oDoc As Document
Dim fDialog As FileDialog
Set fDialog = Application.FileDialog(msoFileDialogFolderPicker)
With fDialog
.Title = "Select folder and click OK"
.AllowMultiSelect = False
.InitialView = msoFileDialogViewList
If .Show <> -1 Then
MsgBox "Cancelled By User", , "List Folder Contents"
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
If Left(strPath, 1) = Chr(34) Then
strPath = Mid(strPath, 2, Len(strPath) - 2)
End If
strFileName = Dir$(strPath & "*.dot")
While Len(strFileName) <> 0
Set oDoc = Documents.Open(strPath & strFileName)
strDocName = ActiveDocument.FullName
intPos = InStrRev(strDocName, ".")
strDocName = Left(strDocName, intPos - 1)
strDocName = strDocName & ".dotx"
oDoc.SaveAs FileName:=strDocName, _
FileFormat:=wdFormatXMLTemplate
oDoc.Close SaveChanges:=wdDoNotSaveChanges
strFileName = Dir$()
Wend
End Sub

should do the trick.

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


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
V

Vivian

Thank you both. The reason I have to convert the format is that all the
templates are called from an in-house program and when the office changes to
OFFICE 2007 the in-house system will only look for dotx not dot.
 

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