View Single Post
 
Old 02-05-2024, 11:27 AM
Kriger1102 Kriger1102 is offline Windows 10 Office 2013
Novice
 
Join Date: Feb 2024
Posts: 3
Kriger1102 is on a distinguished road
Default Modified based on suggesoitn

I have saved the document as a Macro Word, the Drop down lost under impact category is set to ran macro "NSIR" on exit. I kinda recorded a macro of inserting a building block and modified the VBA to insert the table as a building block instead based on the suggestion?? Nothing appears to be happening.

Sub NSIR()
Select Case ActiveDocument.FormFields("ddImpact").Result

Case "Minor Harm"
Selection.Range.ContentControls.Add (wdContentControlBuildingBlockGallery)
Selection.ParentContentControl.BuildingBlockType = wdTypeTables
Application.Templates( _
"C:\Users\wuz1\AppData\Roaming\Microsoft\Docum ent Building Blocks\1033\15\Building Blocks.dotx" _
).BuildingBlockEntries("NSIRDetail").Insert Where:=Selection.Range, _
RichText:=True
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Case "Moderate Harm"
Selection.Range.ContentControls.Add (wdContentControlBuildingBlockGallery)
Selection.ParentContentControl.BuildingBlockType = wdTypeTables
Application.Templates( _
"C:\Users\wuz1\AppData\Roaming\Microsoft\Docum ent Building Blocks\1033\15\Building Blocks.dotx" _
).BuildingBlockEntries("NSIRDetail").Insert Where:=Selection.Range, _
RichText:=True
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1

Case "Severe Harm"
Selection.Range.ContentControls.Add (wdContentControlBuildingBlockGallery)
Selection.ParentContentControl.BuildingBlockType = wdTypeTables
Application.Templates( _
"C:\Users\wuz1\AppData\Roaming\Microsoft\Docum ent Building Blocks\1033\15\Building Blocks.dotx" _
).BuildingBlockEntries("NSIRDetail").Insert Where:=Selection.Range, _
RichText:=True
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1

End Select
End Sub

This is my code for it. Nothing is happening.
Attached Files
File Type: docm TEST.docm (28.8 KB, 4 views)
Reply With Quote