Macros - Microsoft Word 2010

  1. OfficeHelpSG

    OfficeHelpSG New Member

    Joined:
    Aug 28, 2011
    Posts:
    1
    Likes Received:
    0
    Local time:
    16:44
    My System
    Loading...

    Hello,
    I'm using Microsoft Word 2010, and every Macro I try and create for a letterhead, does not work. The formatting of my text is not shown when I run the macro! The size changes, and the bold does not apply. The weird thing is everytime I run the macro in the same document or in a different document, it doesnt ever show the same.
    I'd like a letterhead macro to turn out like this (The top line should be in 16, the second line in 10 and the last two lines in size 12):


    Turner and Sons Accouting Pty Ltd
    ABN: 22 333 111 555
    22 Kings St, Sydney 2000
    Phone: (02) 9675 4444 Fax: (02) 9675 4443



    The code for the text is:
    Sub Letterhead()
    '
    ' Letterhead Macro
    '
    '
    Selection.TypeText Text:="Turner and Sons Accounting Pty Ltd"
    Selection.TypeParagraph
    Selection.Font.Bold = wdToggle
    Selection.Font.Size = 10
    Selection.TypeText Text:="ABN: 22 333 111 555"
    Selection.TypeParagraph
    Selection.Font.Size = 12
    Selection.TypeText Text:="22 Kings St, Sydney 2000"
    Selection.TypeParagraph
    Selection.TypeText Text:="Phone: (02) 9675 4444 Fax: (02) 9675 4443"
    End Sub
  2. DCiAdmin

    DCiAdmin Well-Known Member

    Joined:
    Sep 30, 2008
    Posts:
    1,907
    Likes Received:
    274
    Local time:
    01:44
    My System
    Loading...

    Hello & Welcome, OfficeHelpSG :)

    I'll get your issue marked as OPEN to attract the attention of those experienced in Office Macros that frequent PCHF. Wish I had more macro experience....

    For future posts, it would be most helpful if you could complete your [​IMG] portion of the User Profile. That would put your system's information in the small computer icon just right of your name. That will "travel with you" at PCHF so we don't have to ask for it again. Be sure to mark them to be visible. The default is NOT to show them.

    Please know that our Staff of Volunteers come from locations around the world so time zones play a big part in how quickly the person with the answer is available to address your question. Your patience is appreciated!
  3. suspended

    suspended Active Member Tech Member Elite Member

    Joined:
    May 15, 2011
    Posts:
    704
    Likes Received:
    113
    Local time:
    02:44
    My System
    Loading...

    The changes I made to your macro are highlighted:
    Code:
    Sub Letterhead()
    '
    ' Letterhead Macro
    '
    '
    [COLOR=Blue]Selection.Font.Bold = wdToggle
    Selection.Font.Size = 16[/COLOR]
    Selection.TypeText Text:="Turner and Sons Accounting Pty Ltd"
    Selection.TypeParagraph
    [COLOR=Blue]Selection.Font.Bold = wdToggle[/COLOR]
    Selection.Font.Size = 10
    Selection.TypeText Text:="ABN: 22 333 111 555"
    Selection.TypeParagraph
    [COLOR=Blue]Selection.Font.Bold = wdToggle[/COLOR]
    Selection.Font.Size = 12
    Selection.TypeText Text:="22 Kings St, Sydney 2000"
    Selection.TypeParagraph
    Selection.TypeText Text:="Phone: (02) 9675 4444 Fax: (02) 9675 4443"
    End Sub
    
    I get the results you wanted when I run the macro as shown:

    Turner and Sons Accounting Pty Ltd
    ABN: 22 333 111 555
    22 Kings St, Sydney 2000
    Phone: (02) 9675 4444 Fax: (02) 9675 4443

    The document is attached.

    Attached Files:

    DCiAdmin likes this.
Similar Threads
Forum Title Date
Software Support Tutorials on recording macros in Microsoft Word Feb 10, 2013
Software Support Word can't find macros after code module rename Aug 19, 2013
Software Support Need Tutorial-Recording Macros in Word Jan 17, 2013
Software Support tutorials on recording macros in Word? Aug 15, 2011