>I have a form with a bookmark called currentdate. I want to use VBA to add
>the current date in the format of September 27, 2007. Everything I have
>tried has given me an error. Can someone help with the syntax on this?
>
>Thanks for your help.
Jay, thanks so much for your response. I just knew that was what I needed .
Unfortunately I put it in my code and I am getting the same error as before.
The error that I am getting is: Wrong number of arguments or invalid
property assignment. It stops with "Format" highlighted.
This is the part of the code that I thinks affects this:
Dim odoc As Word.Document
Set odoc = Documents("allnotices.doc")
odoc.Bookmarks("currentDate").Range.Text = FORMAT(Now, "MMMM dd, yyyy")
I have several other variables and bookmarks and they are all working OK.
But a simple date has got me stumped. Can you tell what I am missing from
this?
There is one issue that might also affect it. I am working with a document
called Allnotices. Under certain circumstances, another document is
inserted into my current document (thus becoming part of Allnotices.) That
inserted document is the one that has the bookmarks. Would the fact that the
second part of the document is not there when it compiles have any effect on
this? It does not seem to affect any of the other variables, but they are
all inputs of one sort or another. Hopefully I just don't have something
declared and it will be a simple fix. (Or maybe there is a better way to do
this. What I am trying to avoid is having the user input the date.)
Thanks for your help.
> >I have a form with a bookmark called currentdate. I want to use VBA to add
> >the current date in the format of September 27, 2007. Everything I have
[quoted text clipped - 15 lines]
> Microsoft Word MVP FAQ: http://word.mvps.org
> Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
Jay Freedman - 28 Sep 2007 17:13 GMT
I don't believe the location of the bookmarks has anything to do with the
error. If VBA couldn't find the bookmark, you'd get a different error, "The
requested member of the collection does not exist".
The Format function is built into VBA. If you put the cursor on the word
Format in your code and press F1, you should get the Help topic about the
function, which shows the proper syntax. It has one required argument and
three optional ones, so passing the first two ("expression" and "format" in
the syntax statement, corresponding to Now and "MMMM dd, yyyy" in your code)
is completely OK.
What could be happening -- though it's a low probability -- is that you have
another Format function defined by some code in your template or a global
add-in, and VBA is looking at the argument list in that function's
definition. Does the word FORMAT really appear in all caps in your code? If
so, that's a clue that something like that is wrong, as the built-in
function's name is automatically changed to Format.

Signature
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
> Jay, thanks so much for your response. I just knew that was what I
> needed . Unfortunately I put it in my code and I am getting the same
[quoted text clipped - 47 lines]
>> Email cannot be acknowledged; please post all follow-ups to the
>> newsgroup so all may benefit.