Copy and paste to word header

  • Hi,


    I have made a mscro in Excel that can copy cells and paste them into the header of a Word document.


    After paste then the Word document is viewed in normal mode. I want it to be viewed in Print Layout View.


    I know that it's Word that don't do as I want it to do. But since the macro is in Excel and Word is "controlled" by Excel then i do believe that I have to ask here.


    I have attached the Excel file with the macro and the Word document in the same .zip file.


    alring

  • Re: Copy and paste to word header


    Alring,


    Ah! With an "Above average" experience this should have been childs play.



    Recorded the following Word it'self when setting to print view.

    Code
    ActiveWindow.View.Type = wdPrintView



    just added your word object in the excel vbe


    Code
    wdapp.ActiveWindow.View.Type = wdPrintView
  • Re: Copy and paste to word header


    Hi iwrk4dedpr
    Maybe is should be childs play but it's not. For me. I have tried your code many times in different ways and all of them with the same result. Word is in normal view. Now the code look like this:



    Maybe I need to find my inner child to solve this. But right now Can't I find it.


    Alring

  • Re: Copy and paste to word header


    Alring,


    My comment wasn't meant to be taken seriously!!!!!


    Not sure what the difference is. I added the indicated line and all worked fine for me.


    I don't do much with Word, but if you step through the line of code what does it do or doesn't it do? Does the word application even flicker like it tried to do something????

  • Re: Copy and paste to word header


    Hi iwrk4dedpr


    Maybe it's because I use Windows XP and Excel/Word 2003 and not 2000.


    I don't know how to run a macro step by step. But it seems that Word is trying to do something. If I replace the last IF-statement so it look liik the code you gave me then I get a message saying:


    "One of the values passed to this method or property is put of range."


    So I need to have all the IF-Statement.


    Alring

  • Re: Copy and paste to word header


    Hi


    Now I got the solution for my problem. See below:


    Maybe someone can move this back to Excel help, because it's a Excel VBA.



    this macro also print and close the document.


    alring

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!