none
Microsoft Word Macros RRS feed

  • Question

  • Hi can i use Microsoft Word Macro to Add my Company name in the Printing Document

    Hi i dun want to write my company name in the Document but i want my company name  in the print out of the word document

    How to do this ?

    • Moved by Kee Poppy Monday, February 28, 2011 8:06 AM (From:Visual Basic General)
    Friday, February 25, 2011 8:25 AM

All replies

  • Hi can i use Microsoft Word Macro to Add my Company name in the Printing Document

    Hi i dun want to write my company name in the Document but i want my company name  in the print out of the word document

    How to do this ?

    Hi,

    Please try the VBA forum.>>

    http://social.msdn.microsoft.com/Forums/en-US/isvvba/threads

    or the WordDEV forum.>>

    http://social.msdn.microsoft.com/Forums/en-US/worddev/threads

     

    or the last forum in this area on social.answers .>>

    http://social.answers.microsoft.com/Forums/en-US/category/officeword

     

    or this forum area on social.technet .>>

    http://social.technet.microsoft.com/Forums/en-US/word/threads



    Regards,

    John

    Click this link to see how to insert a picture into a forum post.
    Saturday, February 26, 2011 12:28 AM
  • *Where* in the printout do you want it?
     
    --
     
     
     
     

    Graham Mayor - Word MVP
    www.gmayor.com
    Posted via the Communities Bridge
    http://communitybridge.codeplex.com/
    Monday, February 28, 2011 8:52 AM
  • i want my comapny name embedded on top right hand corner

    Tuesday, March 1, 2011 3:46 AM
  • Without knowing more about your document I can only make guesses about the
    content, but the following macro may help point the way:
     
    Sub InsertCompanyInHeaderandPrint()
    Dim oDoc As Document
    Dim strPath As String
    Dim oSection As Section
    Dim oHeader As HeaderFooter
    Dim oRng As Range
    Dim intPos As Integer
    Dim strCompany As String
    Set oDoc = ActiveDocument
    oDoc.Save
    strCompany = "The name of the company"
    Set oSection = oDoc.Sections(1)
    For Each oHeader In oSection.Headers
        If oHeader.Exists Then
            Set oRng = oHeader.Range
            With oRng
                If Len(oRng) > 1 Then
                    .InsertParagraphBefore
                    .Start = oHeader.Range.Start
                    .End = oHeader.Range.Paragraphs(1).Range.End
                End If
                .Font.Name = "Arial"
                .Font.Bold = False
                .Font.Italic = False
                .Font.Size = "12"
                .ParagraphFormat.Alignment = wdAlignParagraphRight
                .Text = strCompany
            End With
            Exit For
        End If
    Next oHeader
    strPath = oDoc.FullName
    oDoc.PrintOut Background:=False
    oDoc.Close wdDoNotSaveChanges
    Documents.Open strPath
    End Sub
     
    --
     
     
     
     

    Graham Mayor - Word MVP
    www.gmayor.com
    Posted via the Communities Bridge
    http://communitybridge.codeplex.com/
    Tuesday, March 1, 2011 6:56 AM
  • Hi Mr.Graham Mayor  Thank u for ur reply  i need to run this macro when the print operation executes

    2. can i avoid the following infos in the last page of print out

    Filename: SharePoint Setup.docx

     Directory: F:

    Template: C:\Documents and Settings\XXXX\Application Data\Microsoft\Templates\Normal.dotm

    Title: 

    Subject: 

    Author: XXXXXXXXX

    Keywords: 

    Comments: 

    Creation Date: 12/14/2010 4:30:00 PM

    Change Number: 2

    Last Saved On: 3/2/2011 11:02:00 AM

    Last Saved By: XXXX

    Total Editing Time: 8 Minutes

    Last Printed On: 3/2/2011 11:02:00 AM As of Last Complete Printing 

    Number of Pages: 2 

    Number of Words: 67 

    Number of Characters: 349 (approx.)

    Wednesday, March 2, 2011 3:21 AM
  • Rename the macro to Sub FilePrint() to intercept the print command. Note
    that this will then apply to all documents, as the document template is
    stated to be normal.dotm, so it would be better simply to add a button to
    the QAT (Quick Access Toolbar) or the ribbon to print such documents.
     
    Add the line
    Options.PrintProperties = False
    before
    oDoc.PrintOut Background:=False
     
    or simply uncheck the Word Option 'print document properties'
     
    --
     
     
     
     

    Graham Mayor - Word MVP
    www.gmayor.com
    Posted via the Communities Bridge
    http://communitybridge.codeplex.com/
    • Marked as answer by Bruce Song Wednesday, March 9, 2011 11:26 AM
    • Unmarked as answer by sivakl_2001 Wednesday, March 23, 2011 9:52 AM
    Wednesday, March 2, 2011 9:22 AM
  • Hi Graham I tried

    Options.PrintProperties = False but nothing happened still printing the Properties

    how to avoide this propertied by coding

     

    Friday, March 18, 2011 7:07 AM
  • Hi Graham Ur code Working find but one problem

    Normally if we hit the Print button of word document it will show the Print window to choose Printer, Page Range and Copies right but this macro executed when the i hit print button don't show me the Print Option Window

    Please Help Me


    Friday, March 18, 2011 7:35 AM
  • Hi Graham R u there? Please help me
    Thursday, March 24, 2011 2:42 AM
  • Sorry - I missed your last message :( To display the print dialog and perform the same function you need a couple of minor modifications:

     

    Dim oDoc As Document
    Dim strPath As String
    Dim oSection As Section
    Dim oHeader As HeaderFooter
    Dim oRng As Range
    Dim intPos As Integer
    Dim strCompany As String
    Dim bPrintOptions As Boolean
    Set oDoc = ActiveDocument
    oDoc.Save
    strCompany = "The name of the company"
    Set oSection = oDoc.Sections(1)
    For Each oHeader In oSection.Headers
        If oHeader.Exists Then
            Set oRng = oHeader.Range
            With oRng
                If Len(oRng) > 1 Then
                    .InsertParagraphBefore
                    .Start = oHeader.Range.Start
                    .End = oHeader.Range.Paragraphs(1).Range.End
                End If
                .Font.Name = "Arial"
                .Font.Bold = False
                .Font.Italic = False
                .Font.Size = "12"
                .ParagraphFormat.Alignment = wdAlignParagraphRight
                .Text = strCompany
            End With
            Exit For
        End If
    Next oHeader
    strPath = oDoc.FullName
    bPrintOptions = Options.PrintBackground
    Options.PrintBackground = False
    Options.PrintProperties = False
    Dialogs(wdDialogFilePrint).Show
    Options.PrintBackground = bPrintOptions
    oDoc.Close wdDoNotSaveChanges
    Documents.Open strPath


    Graham Mayor - Word MVP
    www.gmayor.com
    • Marked as answer by sivakl_2001 Thursday, March 24, 2011 7:21 AM
    • Unmarked as answer by sivakl_2001 Monday, April 11, 2011 10:53 AM
    Thursday, March 24, 2011 5:49 AM
  • hi Graham ur code working fine

    Can i create simple installer for this macro

    beacuse i need to put this macro in all of my colleague's machine

    so can i create simple installer for this macro

    pls guide me

    Thursday, March 24, 2011 7:24 AM
  • The simplest solution would be to save the macro in a (macro enabled for Office 2007/2010) template and provide that template to your colleague to be used as an add-in.

    Or give him the listing and a link to - http://www.gmayor.com/installing_macro.htm 


    Graham Mayor - Word MVP
    www.gmayor.com
    Thursday, March 24, 2011 2:02 PM
  • hi graham can u tell me how to sava the macro in a template
    Friday, March 25, 2011 4:31 AM
  • Please read installation instructions in the link I posted yesterday - http://www.gmayor.com/installing_macro.htm Copy the macro to a module in the current document and save it as a macro enabled template.

    Graham Mayor - Word MVP
    www.gmayor.com
    Friday, March 25, 2011 5:31 AM
  • Hi sivakl2001,

    I see you've been posting about the same question at:
    http://www.msofficeforums.com/vba/6615-macro-print.html 

    For cross-posting etiquette, please see:
    http://www.excelguru.ca/node/7

    I don't appreciate finding that I've spent my time helping you to solve a problem only to find that you've had Graham spending his time on the same problem and you haven't bothered to tell either party about the help you've already been given. I'm sure Graham won't be impressed either.


    Cheers
    Paul Edstein
    [MS MVP - Word]

    Friday, March 25, 2011 6:27 AM
  • hi macropod i posted the same question there because i wonder any other solution for my pbm tats all

    Graham helped me fully to overcome this problem


    Friday, March 25, 2011 6:33 AM
  • hi graham i had read the instruction in the link i couldn't find how to install in other machines or how to update normal.dotm in other machines

    i hav some other macro's, can i hide all of my macro's

    Friday, March 25, 2011 7:15 AM
  • Hi sivakl2001,

    No-one objects to you posting the same question in multiple forums.

    What I and many others object to is not being told that you're doing this (and being given the relevant links). The failure to do so simply ends up wasting a lot of peoples' valuable time, needlessly working on aspects of a problem that someone else has already worked on.


    Cheers
    Paul Edstein
    [MS MVP - Word]
    Friday, March 25, 2011 7:23 AM
  • hi mr.macropod

    i didn't ask u the same question right, i asked  some doubts from Graham's reply

    http://www.msofficeforums.com/vba/6615-macro-print.html#post15183

    anyway if u think i wasted ur time i am sorry

    Friday, March 25, 2011 7:32 AM
  • Hi Graham mayor

    the mocro code Does not work in Microsoft Office Word 2010

    FilePrint is working in Word 2007  but the command doesn't fire if i press Print in the Word 2010

    Monday, April 11, 2011 7:45 AM
  • hi i post in other forum cs may be i could get diffrent solution from diff developers

    i dun know u r the one guy answer in all forum

    Tuesday, April 12, 2011 3:26 AM
  • ok  i did cross-posting , do u wan answer my question or jus u want post this
    Tuesday, April 12, 2011 3:36 AM
  • As I said before, there is no objection to cross-posting. But you owe everyone concerned the courtesy of providing links to the cross-posts.

    People who get a reputation for cross-posting and refusing to provide all the links soon find others unwilling to help them. In some of the forums you've been cross-posting to, this behaviour will get you banned as well.


    Cheers
    Paul Edstein
    [MS MVP - Word]
    Tuesday, April 12, 2011 3:43 AM
  • I don't presently have Office 2010 installed, so I can't comment on issues specific to that product.
    Cheers
    Paul Edstein
    [MS MVP - Word]
    Tuesday, April 12, 2011 3:45 AM
  • in future i won't Cross-Post

    can u tell me is it possible in the word 2010 to intercept with Print command

    Tuesday, April 12, 2011 4:26 AM