Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 09-07-2022, 12:09 AM
Cendrinne's Avatar
Cendrinne Cendrinne is offline Help with a script for IF with Cell Border LineWidth less than X, then put Y Windows 10 Help with a script for IF with Cell Border LineWidth less than X, then put Y Office 2019
Competent Performer
Help with a script for IF with Cell Border LineWidth less than X, then put Y
 
Join Date: Aug 2019
Location: Montreal Quebec Canada
Posts: 200
Cendrinne is on a distinguished road
Default Help with a script for IF with Cell Border LineWidth less than X, then put Y

Hello Pros,
Again, I'm stuck on this script I found on the web, I've just modified it to my needs.
It Works, BUT, it has No Dim, so being on Option Explicit, doesn't work.
If I remove ''Option Explicit'', it's slow for a few tables on a couple of pages as a test, yet it checks every cell, so normal it's slow, but it does Work.

I'm trying to fix the macro to have Option Explicit, along with Dim, etc. Reason, because all my scripts are for Option Explicit.
Whatever I try, it either does Nothing, or I get an error message.

I hate to give up, so PLEASE, could you help me.

Cause on tables in a word document, people don't open the screen big enough, and they assume, a 0.75 pt, could be a 0.50 pt, so on same line or row, I see both borders.

It's very long when you have to verify over 50 tables in a document to fix them.

On that same web page, someone created a macro with Dim, but it add's borders from the enum (-6 to -1), from these data: WdBorderType Enum (Microsoft.Office.Interop.Word) | Microsoft Docs

Code:
Sub FixCellBorders()
'Found on Web https://wordribbon.tips.net/T013081_Setting_a_Default_Table_Border_Width
   On Error Resume Next
    ' Work through all tables in document
    For Each objTable In ActiveDocument.Tables
        ' Work through all cells in each table
        For Each objCell In objTable.Range.Cells
            ' Work through all borders in each cell
            For Each objBorder In objCell.Borders
                ' Check if line weight is less than 1.00 pt
                If objBorder.LineWidth = wdLineWidth050pt _
                  Or objBorder.LineWidth = wdLineWidth075pt Then
                    ' too thin, change it
                    objBorder.LineWidth = wdLineWidth100pt
                End If
            Next objBorder
        Next objCell
    Next objTable
End Sub
I'm very clueless, so any insights would be so appreciative

Cendrinne
Reply With Quote
 

Tags
helpme, if command, wdlinewidth



Similar Threads
Thread Thread Starter Forum Replies Last Post
cell border lineweights bkcell Excel 0 08-20-2017 09:55 AM
Can I type over a cell with a border? Juju37 Excel 0 01-20-2015 07:40 AM
Help with a script for IF with Cell Border LineWidth less than X, then put Y Need to remove a line that isn't a cell border msbytes Word 4 08-15-2011 09:21 AM
Help with a script for IF with Cell Border LineWidth less than X, then put Y Cell border markg2 Excel 10 04-12-2011 05:05 PM
Help with a script for IF with Cell Border LineWidth less than X, then put Y Table cell border markg2 Word Tables 2 01-15-2010 05:22 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:43 PM.


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