Word Autofit Table Contants macro

N

NoSurprises

Morning Everyone :eek:)

I'm looking for a macro that will search a specified folder, and adjust all
tables (coloums mainly) within the word document to Autofit. We have a
number of documents that require adjusting (100's), and am hoping that
someone here will know of such a macro. For use primarily in Wordd 2000,
but also Word 2003

Any ideas?
 
D

Doug Robbins - Word MVP

The following macro should do that, BUT make sure that you have a copy of
the documents so that there a no surprises if the result is not exactly what
you want

Dim MyPath As String
Dim MyName As String
Dim MyDoc As Document
Dim MyTable As Table

'let user select a path
With Dialogs(wdDialogCopyFile)
If .Display() <> -1 Then Exit Sub
MyPath = .Directory
End With

'strip quotation marks from path

If Len(MyPath) = 0 Then Exit Sub

If Asc(MyPath) = 34 Then
MyPath = Mid$(MyPath, 2, Len(MyPath) - 2)
End If

'get files from the selected path
'and set the AllowAutoFit property for each
MyName = Dir$(MyPath & "*.*")
Do While MyName <> ""
Set MyDoc = Documents.Open(MyPath & MyName)
For Each MyTable In MyDoc.Tables
MyTable.AllowAutoFit = True
Next MyTable
MyDoc.Close wdSaveChange
MyName = Dir
Loop


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - 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