Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-16-2016, 02:47 PM
Supunsam Supunsam is offline Change Cell Margin with a Macro Windows 10 Change Cell Margin with a Macro Office 2013
Novice
Change Cell Margin with a Macro
 
Join Date: May 2016
Posts: 2
Supunsam is on a distinguished road
Question Change Cell Margin with a Macro

Hi guys,

I'm very new to VBA and i would really appreciate if you guys can help me on this macro i'm working on. I have word document contains tables formatted with cell margin option in word. I was trying to convert these in to Paragraph indents. So far i came up with this:



Sub CellPadding()

Dim myCell As Cell
Dim myRow As Row
Dim myTable As Table

Set myTable = Selection.Tables(1)

With myTable

For Each myRow In myTable.Rows
For Each myCell In myRow.Cells

If myCell.LeftPadding = CentimetersToPoints(0.5) Then
Set ParagraphForamat.LeftIndent = 72

End If

Next
Next

End With

End Sub


I might did something stupid in this macro. Please help me to solve this issue. basically i want to change the cell padding value to paragraph indent in the cell.
Reply With Quote
  #2  
Old 05-16-2016, 04:22 PM
macropod's Avatar
macropod macropod is offline Change Cell Margin with a Macro Windows 7 64bit Change Cell Margin with a Macro Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,340
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Cross-posted at: https://social.msdn.microsoft.com/Fo...?forum=worddev
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184

Code:
Sub Demo()
Application.ScreenUpdating = False
Dim oCell As Cell
With Selection
  If .Information(wdWithInTable) = False Then Exit Sub
  For Each oCell In .Tables(1).Range.Cells
    With oCell
      If Round(PointsToCentimeters(.LeftPadding), 2) = 0.5 Then
        .Range.ParagraphFormat.LeftIndent = 72
      End If
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 05-16-2016, 11:15 PM
Supunsam Supunsam is offline Change Cell Margin with a Macro Windows 10 Change Cell Margin with a Macro Office 2013
Novice
Change Cell Margin with a Macro
 
Join Date: May 2016
Posts: 2
Supunsam is on a distinguished road
Default

Hi guys,

First of all i like to apologize for this. I just wanted to find a solution as soon as possible and wasn't aware of this issue. I can assure this wont happen again in the future and i will remove my cross post from msdn.
Reply With Quote
Reply

Tags
cell padding, cell padding vba, cells word vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Change Cell Margin with a Macro Margin change for selected text in Word 7 Richtriebe Word 4 03-14-2016 11:57 AM
Word Table internal cell margin? Powelland Word Tables 2 12-09-2015 11:42 AM
Change Cell Margin with a Macro Change a document to A4 with Left margin 1.5 from Letter size and 1.27 margin Reuven Word 1 12-03-2015 04:25 PM
Macro to change cell references SaneMan Excel Programming 6 10-01-2013 02:49 PM
Change Cell Margin with a Macro Creating a Macro to change the shading of a cell Triscia Word VBA 3 01-30-2013 04:18 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:07 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