Results 1 to 6 of 6
  1. #1
    liner
    Guest
    I regularly have to import parts of Excel files into Word. I copy the range in Excel, and then paste the information into Word. At the lower right hand of the new table is a menu that allows me to use the default Word format for the table.

    All well and good. My text formatting changes to what I want; the box outlines change to what I want. Everything works...............except: The imported table has the row height set, and I have to go into the table properties and remove the check for the row that says use fixed height.

    It is a nuisance I know, but do you know an easy way to get rid of that height restriction?

    Have you got an easy way to put it into a macro that includes the paste as default style?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You could use a macro like this:

    Code:
    Sub PasteXLTable()
      On Error GoTo ExitHere
      Selection.PasteExcelTable False, True, False
      Selection.MoveUp Unit:=wdLine, Count:=1
      Selection.Tables(1).Rows.HeightRule = wdRowHeightAuto
    ExitHere:
    End Sub
    The On Error line skips the rest of the code if something goes wrong, for example if there is no Excel table on the clipboard.

  3. #3
    liner
    Guest
    [quote name='HansV' post='775765' date='18-May-2009 14:21']You could use a macro like this:

    Code:
    Sub PasteXLTable()
      On Error GoTo ExitHere
      Selection.PasteExcelTable False, True, False
      Selection.MoveUp Unit:=wdLine, Count:=1
      Selection.Tables(1).Rows.HeightRule = wdRowHeightAuto
    ExitHere:
    End Sub
    The On Error line skips the rest of the code if something goes wrong, for example if there is no Excel table on the clipboard.[/quote]

    It works fine. Thank you. If only I could understand Word as well as you do.

  4. #4
    liner
    Guest
    Hello Hans

    This little macro is working fine. There is one more thing if possible. As imported, at a page break, the cell can break within the cell. I want that to be denied also. Can you give me the command for that setting, so as to be able to add it to the macro.

    And, by the way, where can I learn more about these commands?

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Add the following line to the macro, above ExitHere:

    Selection.Tables(1).Rows.AllowBreakAcrossPages = False

    To learn about these commands, click in a word such as AllowBreakAcrossPages in the Visual Basic Editor, then press F1.

  6. #6
    liner
    Guest
    Thank you very much. And, I will look at those other commands.

Posting Permissions

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