Monday, September 13, 2010

Date & Time Functions in VBA Functions:-

Date
DateValue
Month
Weekday
DateAdd
Day
MonthName
WeekdayName
DateDiff
Format
Dates
Now
Year
DatePart
Hour
TimeSerial
DateSerial
Minute
TimeValue

Information Functions in VBA Functions:-

IsDate
IsError
IsNull
IsNumeric

Numeric / Mathematical Functions in VBA Functions:-

Abs
Fix
Rnd
Tan
Atn
Format
Numbers
Round
Cos
Int
Sgn
Exp
Log
Sin

String Functions in VBA Functions:-

View an Listing in VBA:-
========================

Asc
InStrRev
Replace
Trim
Chr
LCase
Right
UCase
Concatenate with &
Left
RTrim
Val
CurDir
Len
Space
Format
Strings
LTrim
Str
InStr
Mid
StrConv

Monday, August 2, 2010

Assigning a Macro to a Shortcut Key:-

Word allows you to assign macros or commands to specific key combinations. These key combinations are referred to as shortcut keys, and when used they result in the macro or command being executed. When you first create a macro by recording it, Word gives you the opportunity to assign the macro to a specific key combination. If you later want to change the key combination, you can follow these steps:

1. Select Customize from the Tools menu. You will see the Customize dialog box.
2. Click on the Keyboard button. Word displays the Customize Keyboard dialog box. (Click here to see a related figure.)
3. Scroll through the Categories list and select the Macros category. The list at the right side of the dialog box changes to show the currently available macros.
4. In the Macros list, select the macro you want assigned to the shortcut key.
5. With the insertion pointer in the Press New Shortcut Key box, press the shortcut key you want to use. For instance, if you want to use Ctrl+Alt+J, press that.
6. Just below the Press New Shortcut Key box you can see whether the shortcut key is already assigned to a different function.
7. Click on Assign.
8. Repeat steps 4 through 7 for each change you want to make.
9. Click on Close.

Aligning a Paragraph in a Word Macro:-

Word allows a rich set of formatting attributes for text in a document. You can control the alignment of a paragraph by using the following VBA statement:

Selection.Paragraphs.Alignment = position

where position is one of the constants shown in the following table:-

Constant Result
wdAlignParagraphLeft Formats the current paragraph as left justified
wdAlignParagraphCenter Formats the current paragraph as centered
wdAlignParagraphRight Formats the current paragraph as right justified
wdAlignParagraphJustify Formats the current paragraph so it expands to the left and right margins

Adding a Macro to a Toolbar:-

For instance, you can create a macro, and then add it to a toolbar. How you do this depends on which version of Word you are using.

If you are using a version of Word prior to Word 2007, then follow these steps:

1. Choose Customize from the Tools menu. Word displays the Customize dialog box.
2. Make sure the Toolbars tab is selected. (Click here to see a related figure.)
3. In the list of toolbars, make sure there is a check mark beside the toolbar to which you want your macro added. The check mark ensures that the toolbar is displayed on the screen.
4. Click on the Commands tab.
5. In the list of Categories, choose the Macros entry. Your macros should then appear in the Commands list.
6. In the Commands list, select the macro you want assigned to a toolbar.
7. Using the mouse, drag the macro from the Commands list to the location on the toolbar where you want it to appear.
8. When you drop the macro, it appears on the toolbar.
9. To add more macros, repeat steps 6 through 8.
10. Click on Close.

Word 2007 is different; it doesn't technically have toolbars like older versions of Word had. You can't make additions or changes to the ribbon, but you can add macros to the Quick Access toolbar. Follow these steps:

1. Click the Office button and then click Word Options. Word displays the Word Options dialog box.
2. At the left side of the dialog box, click the Customize option.
3. Using the Choose Commands From drop-down list, choose Macros.
4. In the list of available macros, select the one you want assigned to the Quick Access toolbar.
5. Click the Add button. The command now appears at the right side of the dialog box.
6. Click the OK button. The command now appears on the Quick Access toolbar.