Seldini
09-03-2014, 06:43 AM
So to preface, my underlying understanding of VBA is just terrible, but I have a project I want to complete, so I'm just bashing through and learning as I go. So if something in the code doesn't make sense, it's probably because I have no idea what I'm doing.
Anyhoo.
I'm stuck on a relatively simple issue which has absolutely stumped me. I have a form with a DTPicker, which lets me choose the date on which a lawsuit was served. That date is then spit out onto a cover sheet page as a bookmark. I want to create a second bookmark which will be the date on which the answer to the complaint is due, 20 days later. But for the sake of elegance, I would rather have it be generated from the first date and not be have second DTPicker for the due date, because it will always be 20 days later.
Dim aServDate As RangeSet aServDate = ActiveDocument.Bookmarks("aServDate").Range
aServDate.Text = Format(Me.DTPicker2.Value, "MMMM d, YYYY")
ActiveDocument.Bookmarks.Add _
Name:="aServDate", _
Range:=aServDate
That is what I currently have for the service date, and it works fine. (The re-adding of the bookmark is to keep the resulting date inside the bookmark so that it can be exported to other documents with INCLUDETEXT). However, whenever I try to use DateAdd, I get a myriad of errors based on whatever I try. Rather than slog through all my trial and error, I'm guessing you fine folks can probably figure this one out pretty quickly.
All I want to do is have a second bookmark added, let's call it aDueDate, which will be the value from DTPicker2 + 20 days. Thanks for any help you can give.
Anyhoo.
I'm stuck on a relatively simple issue which has absolutely stumped me. I have a form with a DTPicker, which lets me choose the date on which a lawsuit was served. That date is then spit out onto a cover sheet page as a bookmark. I want to create a second bookmark which will be the date on which the answer to the complaint is due, 20 days later. But for the sake of elegance, I would rather have it be generated from the first date and not be have second DTPicker for the due date, because it will always be 20 days later.
Dim aServDate As RangeSet aServDate = ActiveDocument.Bookmarks("aServDate").Range
aServDate.Text = Format(Me.DTPicker2.Value, "MMMM d, YYYY")
ActiveDocument.Bookmarks.Add _
Name:="aServDate", _
Range:=aServDate
That is what I currently have for the service date, and it works fine. (The re-adding of the bookmark is to keep the resulting date inside the bookmark so that it can be exported to other documents with INCLUDETEXT). However, whenever I try to use DateAdd, I get a myriad of errors based on whatever I try. Rather than slog through all my trial and error, I'm guessing you fine folks can probably figure this one out pretty quickly.
All I want to do is have a second bookmark added, let's call it aDueDate, which will be the value from DTPicker2 + 20 days. Thanks for any help you can give.