V
VBA_Newbie79
I have written a macro (with lots of help from this board) that copies the
contents of two Excel worksheets into Word. Once the copy is finished, I
need Word to go through a table and delete all rows where the font is
formatted white. Below is the code. I've tried everything I can think to
turn off screen updating and Word visibility, but it does nothing to speed up
the code. Any help you pros can provide would be very much appreciated.
Thanks!
Sub PrintFlowchart()
Dim oRow As Row
Dim oRows As Range
Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Add
wdApp.Visible = False
Word.Application.ScreenUpdating = False
Excel.Application.ScreenUpdating = False
Sheets("Flowchart").Range("A1:V57").Copy
wdApp.Selection.PasteSpecial link:=False,
DataType:=wdPasteMetafilePicture, _
Placement:=wdInLine, DisplayAsIcon:=False
wdApp.Selection.InsertBreak Type:=wdPageBreak
Sheets("Key").Activate
Range("B2").Select
ActiveCell.CurrentRegion.Copy
wdApp.Selection.PasteSpecial link:=False, DataType:=wdPasteRTF
wdApp.Selection.Goto What:=wdGoToTable, Which:=wdGoToFirst, Count:=1,
Name:=""
wdApp.Selection.Tables(1).Select
If wdApp.Selection.Information(wdWithInTable) = False Then Exit Sub
For Each oRow In wdApp.Selection.Tables(1).Rows
If oRow.Cells(1).Range.Font.Color = wdColorWhite Then
oRow.Delete
End If
Next oRow
wdApp.Visible = True
Excel.Application.ScreenUpdating = True
Word.Application.ScreenUpdating = True
Word.Application.Selection.HomeKey Unit:=wdStory
End Sub
contents of two Excel worksheets into Word. Once the copy is finished, I
need Word to go through a table and delete all rows where the font is
formatted white. Below is the code. I've tried everything I can think to
turn off screen updating and Word visibility, but it does nothing to speed up
the code. Any help you pros can provide would be very much appreciated.
Thanks!
Sub PrintFlowchart()
Dim oRow As Row
Dim oRows As Range
Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Add
wdApp.Visible = False
Word.Application.ScreenUpdating = False
Excel.Application.ScreenUpdating = False
Sheets("Flowchart").Range("A1:V57").Copy
wdApp.Selection.PasteSpecial link:=False,
DataType:=wdPasteMetafilePicture, _
Placement:=wdInLine, DisplayAsIcon:=False
wdApp.Selection.InsertBreak Type:=wdPageBreak
Sheets("Key").Activate
Range("B2").Select
ActiveCell.CurrentRegion.Copy
wdApp.Selection.PasteSpecial link:=False, DataType:=wdPasteRTF
wdApp.Selection.Goto What:=wdGoToTable, Which:=wdGoToFirst, Count:=1,
Name:=""
wdApp.Selection.Tables(1).Select
If wdApp.Selection.Information(wdWithInTable) = False Then Exit Sub
For Each oRow In wdApp.Selection.Tables(1).Rows
If oRow.Cells(1).Range.Font.Color = wdColorWhite Then
oRow.Delete
End If
Next oRow
wdApp.Visible = True
Excel.Application.ScreenUpdating = True
Word.Application.ScreenUpdating = True
Word.Application.Selection.HomeKey Unit:=wdStory
End Sub