Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2007

Tip: Looking for answers? Try searching our database.

Bulk conversion of .dot to .doc

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Melissa - 13 Apr 2007 04:42 GMT
Hi there,

I need to change about 100 word templates to documents.  Is there a quick
way to do this in bulk, rather than renaming each one?  I am doing this
because I want these documents to be firm precedents and I need them to be
based on one of our templates (usinng templates and add-ins).

Thanks
Jean-Guy Marcil - 13 Apr 2007 06:28 GMT
Melissa was telling us:
Melissa nous racontait que :

> Hi there,
>
[quoted text clipped - 3 lines]
> need them to be based on one of our templates (usinng templates and
> add-ins).

Try something liike this:

'_______________________________________
Option Explicit

'_______________________________________
Public Sub BatchSaveAllAsDoc()

Dim myFile As String
Dim PathToUse As String
Dim PathToSave As String
Dim myDoc As Document

PathToUse = "C:\Test\"
PathToSave = PathToUse & "Doc\"

'Create directory if it does not exist
If Dir(PathToSave, vbDirectory) = "" Then
   MkDir PathToSave
End If

'Set the directory and type of file to batch process
myFile = Dir$(PathToUse & "*.dot")

While myFile <> ""
   'Open template
   Set myDoc = Documents.Open(PathToUse & myFile)
   With myDoc
       .SaveAs PathToSave & Left(myFile, Len(myFile) - 3) & "doc"
       .Close
   End With
   'Next file in folder
   myFile = Dir$()
Wend

End Sub
'_______________________________________

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Melissa - 13 Apr 2007 06:58 GMT
Thanks very much.  That worked a treat.  However, when I open one for the
documents and go to templates and add-ins to attach my template, the box is
greyed out, as if it were still a template.  Do you know of a work-around for
this?

> Melissa was telling us:
> Melissa nous racontait que :
[quoted text clipped - 44 lines]
> End Sub
> '_______________________________________
Jean-Guy Marcil - 13 Apr 2007 13:45 GMT
Melissa was telling us:
Melissa nous racontait que :

> Thanks very much.  That worked a treat.  However, when I open one for
> the documents and go to templates and add-ins to attach my template,
> the box is greyed out, as if it were still a template.  Do you know
> of a work-around for this?

Yes, sorry about this; I should not have used "Documents.Open" with
Templates...

Replace
   Set myDoc = Documents.Open(PathToUse & myFile)
by
   Set myDoc = Documents.Add(PathToUse & myFile)

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Melissa - 15 Apr 2007 23:52 GMT
Thank you very much.  That worked perfectly.  If you have the time, can you
please explain why Documents.Add created the doc without the templates and
add-ins greyed out, but Documents.Open did not, or direct me to a site that
might explain it.

> Melissa was telling us:
> Melissa nous racontait que :
[quoted text clipped - 11 lines]
> by
>     Set myDoc = Documents.Add(PathToUse & myFile)
Jonathan West - 16 Apr 2007 11:06 GMT
> Thank you very much.  That worked perfectly.  If you have the time, can
> you
> please explain why Documents.Add created the doc without the templates and
> add-ins greyed out, but Documents.Open did not, or direct me to a site
> that
> might explain it.

It is a idiosyncrasy of Word. You can never "Save As" a template as a
different file type. But you can create a new document based on a template,
and save that new document. The Documents.Add method is the VBA equivalent
of creating a new document based on a template.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.