Results 1 to 2 of 2

Thread: [FAQ's: OD] How do I record a macro?

  1. #1

    Thread Starter
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    [FAQ's: OD] How do I record a macro?

    To record a macro (in most Office apps) you need to start the recording by going to "Tools > Macro > Record New Macro...". You will then be prompted with a dialog window to fill in and make some choices Fig. 1. Word 2003 was used in this example. Currently, only Word and Excel support the actual recording of a macro, but other Office apps do support Macro manually written code in the VBA editor. A Macro is nothing more then a VBA procedure of code.

    Fig. 1


    For ex.
    "Name:" the name of the macro or procedure name.
    "Assign:" you can sssign the macro to be invoked from a keyboard keypress or a toolbar button click or just leave it unassigned (default). Usually if your recording a macro to identify the necessary code for doing something that you dont know hoiw to is best to leave it unassigned.
    "Store macro in:" This depends on how your going to be using the macro. If you want it to be available in all documents then you will want to store it in your Normal.dot template. If you want it to only be available in a document then store it in that document by choosing it from the dropdown combo.
    "Description:" This is where you can enter in comments for your macro/code procedure. They will appear in the beginning of the code as actuall comments.

    Now click the Ok button and your now Recording your every action, in most cases, and you should see a toolbar appear with the Pause and Stop recording buttons as seen in Fig. 2. If you dont you can still Stop the recording from the "Tools > Macro > Stop Recording" menu item. Do the task that you want to automate and then press the stop button. For this example its typing in "Hello World!", Fig. 3

    Fig. 2


    Fig. 3


    You can view the generated code by going into the VBA IDE (press Alt+F11) and in the Modules folder you will see NewMacros module. Select the Module and scroll down to your procedure that you named it in Fig. 1 Name field. Depending on the location that you choose to store the macro in it will either be under the Normal project/Modules NewMacros or DocumentName/Modules NewMacros, see Fig. 4.

    Fig. 4



    Now you have your generated code and can see how Word does it.
    Last edited by RobDog888; May 13th, 2006 at 02:04 PM.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [FAQ's: OD] How do I record a macro?

    Recording Macros in Office 2010

    Click the View menu and choose the Macros ¬¬> Record Macro. See picture attached. This applies to MS Excel, MS PowerPoint, MS Word and other Apps in 2010 as well. Rest remains almost the same as shown above by Rob in post 1.
    Attached Images Attached Images  
    Last edited by Siddharth Rout; Feb 18th, 2010 at 10:58 AM. Reason: Added more text
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width