1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

MS Word 2016 -- I don't understand macros!

Discussion in 'Business Applications' started by bj nick, Jul 18, 2019.

Thread Status:
Not open for further replies.
Advertisement
  1. bj nick

    bj nick Thread Starter

    Joined:
    Jun 10, 1999
    Messages:
    1,729
    So....I've tried to follow online instructions, and have successfully created macros for a few things. HOWEVER....I don't understand the "rules" on how to make the macros work on all documents and computers. I have a desktop and a laptop, and I share docs between them all the time, depending on where I am. All the docs are created on MS Word 2016 (Office 365.) Here are my questions: 1) How do I create macros that will work on the current document and subsequent docs as well? 2) And....work on both computers? 3) How come I can't ever "view" an existing macro to remind myself what the macro is? (it just shows me Visual Basic language, which is incomprehensible to me.) Thanks for any help!
     
  2. lunarlander

    lunarlander

    Joined:
    Sep 21, 2007
    Messages:
    11,574
  3. bj nick

    bj nick Thread Starter

    Joined:
    Jun 10, 1999
    Messages:
    1,729
    Hi, thanks for the response. I'll try the link and see about copying the macros. Yeah, my brother has a programming background and for him the macros are baby stuff, I asked him after posting this, and he said basically what you just said.....but I have no background at all. Anyway, I'll try it out and see what happens, then report back. Thanks!
     
  4. sjtrupp

    sjtrupp

    Joined:
    Nov 18, 2015
    Messages:
    42
    First Name:
    Steven
    You can add notes to the Visual Basic Code by using the ' character before your note (needs to be used for each line). That way to can remind yourself what the macro does.


    ' This will add ....
    ' and it will also ....
     
  5. bj nick

    bj nick Thread Starter

    Joined:
    Jun 10, 1999
    Messages:
    1,729
    I don't understand what "note" means in this context......or how to add anything to VBC....sorry, total ignoramus when it comes to that stuff......
     
  6. sjtrupp

    sjtrupp

    Joined:
    Nov 18, 2015
    Messages:
    42
    First Name:
    Steven
    3) How come I can't ever "view" an existing macro to remind myself what the macro is? (it just shows me Visual Basic language, which is incomprehensible to me.) Thanks for any help!

    A comment, note, explanation. Plain text describing what the macro does.

    Simply add a line, using the enter button and type in what you want say and put the ' character in front of your text. It won't change the program.

    So your coding would go from this:

    Function UserName() As String

    Const lpnLength As Integer = 255
    Dim status As Integer
    Dim lpName, lpUserName As String

    lpUserName = Space$(lpnLength + 1)
    status = WNetGetUser(lpName, lpUserName, lpnLength)
    UserName = Left$(lpUserName, InStr(lpUserName, Chr(0)) - 1)

    End Function


    To look like this:

    Function UserName() As String
    'This code will collect the username from the Microsoft login.
    Const lpnLength As Integer = 255
    (More Incomprehensible code...)


    You can put the note above the function line, if you like or even after it like this:

    Function UserName() As String 'This code will collect the username from the Microsoft login.

    Unfortunately, you can't put the note in bold. I did it to help show the difference.
     
  7. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1230223

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice