ID: Q105683
The information in this article applies to:
When you use Microsoft WordBasic functions in Visual Basic, keywords that return strings--that is, keywords that end in a dollar sign ($)-- must be enclosed in square brackets or an error message will occur.
The following WordBasic instruction returns the current date:
a$ = Date$()
In Visual Basic, the same instruction is specified as follows:
worddate = WordObj.[Date$]()
The following Visual Basic example uses Word's Date$() function to
post the current date in a message box:
Dim WordObj As Object Dim worddate As String Set WordObj = CreateObject("Word.Basic") worddate = WordObj.[Date$]() MsgBox worddate
If you omit the square brackets that surround "Date$", Visual Basic will post the following error message:
Identifier can't end with type-declaration character
The following WordBasic instruction shows the GetBookmark$() function as it might appear in a WordBasic macro:
mark$ = GetBookmark$("Address")
In Visual Basic, the same instruction would be specified as follows:
mark$ = WordObj.[GetBookmark$]("Address")
The following Visual Basic procedure opens the Word document TEST.DOC,
and then uses the WordBasic GetBookmark$() function to return the
text of the "Address" bookmark in a message box:
Sub Command1_Click ()
Dim WordObj As Object
Dim Mark As String
Set WordObj = CreateObject("Word.Basic")
WordObj.FileOpen "D:\WinWord6\Test.doc"
Mark = WordObj.[GetBookmark$]("Address")
MsgBox Mark
End Sub
KBCategory: kbmacro KBSubcategory: Additional query words: 6.0 ole automation word basic word6 word7 6.0a 6.0c 7.0 word95 object visual basic dollar sign brackets function return winword
Keywords : kbole kbmacro
Version : 6.0 6.0a 6.0c 7.0
Platform : WINDOWS
Last Reviewed: February 6, 1998