Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create VBA macro

Status
Not open for further replies.

alla1921

Programmer
Nov 24, 2003
17
US
Can anybody explain how to create and use VBA macro.

Thanks!
 
Tools - macro- macros
type your macro name and press create button
If wan to test
use the following code to display text message

double click on thisdocument
Private Sub Document_Beforerefresh(Cancel As Boolean)
msgbox "Welcome to macros"
End Sub
 
Yep. This is so easy. For real situation, you have to identify the correct objects, methods and properties
 
'finding no of pages in a report
Sub nopages_macro()
Dim rep As busobj.Report
Dim nop As Long
Set rep = Application.ActiveDocument.Reports(1)
nop = rep.NumberOfPages
MsgBox "No. of Pages : " + CStr(nop)
End Sub

'Suppressing No Data to Fetch message
Private Sub Document_BeforeRefresh(Cancel As Boolean)
Application.Interactive = False
End Sub
 
Do you mean run the created macros??? If so Alt + F8 will do or else Tools - > Marco - > Macros.... and select your macro from the list and press Run... Isn't that so easy as well...

Sri
 
As I understand users suposed to know about this macro and know how to activate it.
 
You have the following things to activate the macro, right?
After Refresh
Before Refresh
Before Save
After Save
open
Activate
deactivate
....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top