Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 01-30-2013, 12:34 PM
kaurp kaurp is offline Macro Help Windows 7 64bit Macro Help Office 2010 64bit
Novice
Macro Help
 
Join Date: Jan 2013
Posts: 3
kaurp is on a distinguished road
Default Macro Help


Hi, I'm trying to write a macro that does a few different things. I have somethings working and others I'm having trouble with.

I need it to find a certain word within a table in word, select that row and change the height.

If the first row of a table is blank, delete it.

Convert a table to text if it starts with the word "Notes:" in the first cell.

If a certain page has a word in it but no table, delete that page.

There are some other things it needs to do that I already have working and here is what I have:
Code:
Public Sub ACF() 
     'Updates table of content
    ActiveDocument.TablesOfContents(1).Update 
     
     'Deletes last page if it's blank
    Dim i As Long 
    For i = ActiveDocument.Paragraphs.Count To 1 Step -1 
        If Asc(ActiveDocument.Paragraphs(i).Range.Text) = 12 Then 
            ActiveDocument.Paragraphs(i).Range.Delete 
            Exit For 
        End If 
        If Len(ActiveDocument.Paragraphs(i).Range.Text) > 1 Then 
            Exit For 
        End If 
    Next i 
     
     'Deletes table if they are blank
    Application.ScreenUpdating = False 
    Dim Tbl As Table, cel As Cell, n As Long, fEmpty As Boolean 
    With ActiveDocument 
        For Each Tbl In .Tables 
            n = Tbl.Rows.Count 
            For i = n To 1 Step -1 
                fEmpty = True 
                For Each cel In Tbl.Rows(i).Cells 
                    If Len(cel.Range.Text) > 2 Then 
                        fEmpty = False 
                        Exit For 
                    End If 
                Next cel 
                If fEmpty = True Then Tbl.Rows(i).Delete 
            Next i 
        Next Tbl 
    End With 
    Set cel = Nothing: Set Tbl = Nothing 
    Application.ScreenUpdating = True 
     
     'State table row heights
    Dim oTbl As Table, x As Integer, z As Integer 
    With oTbl 
        For i = .Rows.Count To 1 Step -1 
            With .Rows(i) 
                If .Cells.Count > 1 Then 
                    Set Rng = .Cells(1, 1).Range 
                    If FindText(Rng, "California") = True Then .HeightRule = wdRowHeightAtLeast 
                     
                End If 
            End With 
        Next 
    End With 
     
End Sub

Last edited by macropod; 02-01-2013 at 06:14 PM. Reason: Added code tags & formatting
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I assign a macro to a button when the macro is in my personal workbook? foolios Excel Programming 2 07-27-2011 02:41 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:21 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft