![]() |
|
#5
|
|||
|
|||
|
Quote:
Here's the code. Form named: UserForm3 Text box named: SPB_box Update button named: SPB_updt =*=*=*=*=*=*=*=*=*=*= This is the code associated with the document itself (or all documents) =*=*=*=*=*=*=*=*=*=*= Private Sub Document_SelectionChange(ByVal Sel As Selection) ' If the form is open, update the text box If UserForm3.Visible Then MsgBox "Selection changed - updating spacing" UserForm3.UpdateSpacingBefore End If End Sub Sub ShowUserForm() ' Open the form modelessly (you will be able to work with the document) UserForm3.Show vbModeless ' Run the update even if you haven't changed any paragraphs UserForm3.UpdateSpacingBefore End Sub =*=*=*=*=*=*=*=*=*= This is the code associated with the form =*=*=*=*=*=*=*=*=*=*= Private Sub UserForm_Initialize() ' Update the text box when the form is opened UpdateSpacingBefore End Sub Public Sub UpdateSpacingBefore() Dim spaceBefore As Single On Error Resume Next ' If the paragraph cannot be accessed spaceBefore = Selection.ParagraphFormat.spaceBefore ' Get the "space before" value On Error GoTo 0 ' Return to normal error mode ' Update the text box with the value of "space before" SPB_box.value = spaceBefore End Sub Private Sub SPB_updt_Click() ' Manually update the space before UpdateSpacingBefore End Sub (Disclosure: I used AI to create this code, and it works for me) I'm looking to improve this code, so that when I move focus From paragraph to paragraph - the information in the text box will be updated automatically. |
| Tags |
| auto update, paragraphs, space before |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Automatic Update for Excel Spreadsheet | Frenchy305 | Excel | 3 | 07-14-2017 12:17 PM |
Stop Automatic Date-Update
|
janetb | Word | 10 | 11-10-2016 12:05 AM |
automatic insert hypens until the end of the row and in empty rows between paragraphs
|
Ivica | Word | 3 | 12-28-2015 01:31 PM |
| Automatic Form update | rlmoss44 | Word VBA | 6 | 12-03-2015 09:27 AM |
| help needed for automatic update of footer | sanju71821 | Word | 7 | 07-01-2015 08:18 AM |