Date Field Clear

J

Jenny B.

sGood Afternoon,

After checking the previous posts, I didn't see anything that quite fit what
I'm looking to do and I'm hoping someone can still help. The first program
below fills in two different ranges in the doc (one with the user id and the
other with the date). Unfortunately, it was brought to my attention that
someone might be a drooling moron and click on the box by accident which
would require a clear function.

The second program I tried to set up works to clear the Text Range
(BMRange), but will not clear the Date Field (BMRange1). I've tried several
variations and the best I can come up with what's below where it only deletes
the first text character.

Any thoughts on how to get it to delete the whole date line?

Thanks in advance - Jenny B.


Sub Bookmark()
Dim BMRange As Range
Dim BMRange1 As Range

Application.ScreenUpdating = False

With ActiveDocument
If .ProtectionType <> wdNoProtection Then
.Unprotect Password:="1"
End If
End With

'Identify current Bookmark range and insert text
Set BMRange = ActiveDocument.Bookmarks("Div").Range
Set BMRange1 = ActiveDocument.Bookmarks("Divs").Range
BMRange.Text = Environ("username") & " " & "Dividends"
BMRange1.InsertDateTime datetimeformat:="MMMM dd, yyyy", InsertAsField:=False
'Re-insert the bookmark
ActiveDocument.Bookmarks.Add "Div", BMRange
ActiveDocument.Bookmarks.Add "Divs", BMRange1

ActiveDocument.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True, Password:="1"


Application.ScreenUpdating = True

End Sub
__________________

Sub Clearboxes()

Dim BMRange As Range
Dim BMRange1 As Range

If ActiveDocument.FormFields("Check19").CheckBox.Value = False Then

Set BMRange = ActiveDocument.Bookmarks("Div").Range
Set BMRange1 = ActiveDocument.Bookmarks("Divs").Range
BMRange.Text = ""
BMRange1.Delete

ActiveDocument.Bookmarks.Add "Div", BMRange
ActiveDocument.Bookmarks.Add "Divs", BMRange1

End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top