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 / May 2006

Tip: Looking for answers? Try searching our database.

Word Autofit Table Contants macro

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
NoSurprises - 19 May 2006 08:26 GMT
Morning Everyone :o)

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?
Doug Robbins - Word MVP - 21 May 2006 07:26 GMT
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

Signature

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

> Morning Everyone :o)
>
[quoted text clipped - 6 lines]
>
> Any ideas?
NoSurprises - 22 May 2006 01:08 GMT
Cheers for this, I'll give it a try :o)

NoSurprises

> 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
[quoted text clipped - 41 lines]
> >
> > Any ideas?

Rate this thread:






 
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.