S
Steve C
I created a basic seating chart for our company employees by placing a layout
of our office in the background (header) of a Word document. Using the
Drawing toolbar, I used a rounded rectangle object (with no fill or line)
over each employee's location (not in the header, but the actual document).
This allowed me to create a bookmark for each rounded rectangle object for
each employee location. My goal was to create a small form that allowed a
user to select an employee name, then have my code find the corresponding
bookmark object and color it yellow to highlight where they sit.
I recorded a macro to get me started with the code; I chose Insert >
Bookmark, selected an existing bookmark name (jsmith) and clicked Go To. It
successfully found his rounded rectangle and selected it. After closing the
Bookmark dialog box (and still recording), I clicked the Fill Color button to
color it yellow. I then stopped recording and ended up with the following
code:
Sub SelectBookmark()
Selection.GoTo What:=wdGoToBookmark, Name:="jsmith"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 255, 0) 'make Fill
Color = yellow
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid
End Sub
When I de-select his oval and try running the macro again, I am getting the
following error:
Run-time error '424'
Object required
What is causing the code not to run successfully? Thanks for your help!
of our office in the background (header) of a Word document. Using the
Drawing toolbar, I used a rounded rectangle object (with no fill or line)
over each employee's location (not in the header, but the actual document).
This allowed me to create a bookmark for each rounded rectangle object for
each employee location. My goal was to create a small form that allowed a
user to select an employee name, then have my code find the corresponding
bookmark object and color it yellow to highlight where they sit.
I recorded a macro to get me started with the code; I chose Insert >
Bookmark, selected an existing bookmark name (jsmith) and clicked Go To. It
successfully found his rounded rectangle and selected it. After closing the
Bookmark dialog box (and still recording), I clicked the Fill Color button to
color it yellow. I then stopped recording and ended up with the following
code:
Sub SelectBookmark()
Selection.GoTo What:=wdGoToBookmark, Name:="jsmith"
With ActiveDocument.Bookmarks
.DefaultSorting = wdSortByName
.ShowHidden = False
End With
Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 255, 0) 'make Fill
Color = yellow
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid
End Sub
When I de-select his oval and try running the macro again, I am getting the
following error:
Run-time error '424'
Object required
What is causing the code not to run successfully? Thanks for your help!