![]() |
|
#1
|
|||
|
|||
![]()
Hey
I'm new with vba word. I want to run trough tables and change some properties. I have a document with around 100 tables and when i start the makro, the word document has an error and shuts down after 20 - 30 tables. Can someone tell me why? This is my code for it: Code:
Sub Tabellen_formatieren() Dim i As Integer For i = 1 To ActiveDocument.Tables.Count ActiveDocument.Tables(i).Select With ActiveDocument.Tables(i).Range.Font .Name = "Arial" .Size = 10 .ColorIndex = wdBlack End With With ActiveDocument.Tables(i) .PreferredWidthType = wdPreferredWidthPercent .PreferredWidth = 100 End With Next End Sub Last edited by macropod; 06-07-2018 at 04:35 PM. Reason: Added code tags |
#2
|
||||
|
||||
![]()
With many tables to process, Word is probably not getting enough breathing space for its housekeeping. You're also unecessarily selecting each table, which only adds to the processing overheads. Try:
Code:
Sub Tabellen_formatieren() Application.ScreenUpdating = False Dim i As Long With ActiveDocument For i = 1 To .Tables.Count With .Tables(i) With .Range.Font .Name = "Arial" .Size = 10 .ColorIndex = wdBlack End With .PreferredWidthType = wdPreferredWidthPercent .PreferredWidth = 100 End With If i Mod 25 = 0 Then DoEvents Next End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
It's working, many thanks
![]() BR shu |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
rasika99 | Word VBA | 3 | 12-12-2014 04:16 AM |
[Rich Text Format] - about tables and pictures | cambalinho | Word | 0 | 07-24-2013 01:17 PM |
![]() |
protocoder | Word VBA | 2 | 06-28-2011 02:51 AM |
![]() |
judicial85 | Word | 3 | 12-25-2010 02:02 AM |
Copying format between tables. | daeron | Word Tables | 0 | 06-11-2010 12:09 AM |