Recording and writing own macro using vb script
You can not only record a macro, but write your own macro if you now a little bit of VB. Here’s an example of how to write your own macro in MSWORD. Suppose you want the date to be in a format not provided by the word in the "Insert" menu's date and time option, e.g. dd.mm.yyyy. Then you could just write a small piece of VB code for this. Just create a new macro and name ot “currentdate” then choose to edit it. The VB editor opens with follwing code. Sub currentdate() ' ' currentdate Macro ' Macro recorded 02/09/01 by Amir Kamerkar End Sub This is nothing but the empty macro you just created now add the piece of code as shown below. Sub date2() ' ' date2 Macro ' Macro recorded 02/09/01 by Kamerkar Dim MyDate MyDate = Format(Date, "dd.mm.yyyy") Selection.TypeText Text:=MyDate End Sub The macro is ready for use. You can change the format of the date by changing the above code. |
0 Responses to Recording and writing own macro using vb script
Something to say?