Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have tried many different ways of formatting and no matter what the text is too high off of the bottom of the cell.
VB
'// FORMAT THE WORKSHEET!
        With t_WorkSheet
            '// THE TOTAL WIDTH IS THE CONSTANT...
            Dim t_Remaining As Single = m_TotalExcelWidth
            t_Remaining = m_TotalExcelWidth - ((13 * 4) + 5)

            '.Rows(2).EntireRo  w.ComlumHeight = 20
            '.Rows(2).EntireRow.VerticalAlignment = Excel.XlVAlign.xlVAlignBottom

            '.Columns.Item(PG2A_NO).Cells.VerticalAlignment = Excel.XlVAlign.xlVAlignBottom
            .Columns.Item(PG2A_NO).ColumnWidth = 5
            '.Columns.Item(PG2A_NAME).Cells.VerticalAlignment = Excel.XlVAlign.xlVAlignBottom
            .Columns.Item(PG2A_NAME).ColumnWidth = t_Remaining   '// GET REMAINING!
            .Columns.Item(PG2A_NFIP).ColumnWidth = 13
            .Columns.Item(PG2A_REP).ColumnWidth = 13
            .Columns.Item(PG2A_DEP).ColumnWidth = 13
            .Columns.Item(PG2A_INS).ColumnWidth = 13

            '.Rows(2).EntireRow.AutoFit()
            'With doc2.Tables(2).Rows
            '    .WrapAroundText = True
            '    .DistanceLeft = 20
            '    .DistanceRight = 20
            '    .DistanceTop = 20
            '    .DistanceBottom = 20
            'End With



            For x = 7 To 10
                .Columns.Item(7).Delete()
            Next
        End With

        '************************************************************************
        ' BEFORE PASTING IN EXCEL, ADD IN THE OBJECT NAME AS SectionHdr3 STYLE! *
        '************************************************************************
        '                                           USED TO BE "SectionHdr3"
        t_Doc.Application.Selection.Style = t_Doc.Styles.Item("Sect2and3Hdr")
        t_Doc.Application.Selection.TypeText(Text:="Summary of Values Schedule")
        't_Doc.Application.Selection.TypeParagraph()
        t_Doc.Application.Selection.ParagraphFormat.SpaceBefore = 0
        t_Doc.Application.Selection.ParagraphFormat.SpaceAfter = 0
        t_Doc.Application.Selection.ParagraphFormat.LineSpacing = 1
        t_Doc.Application.Selection.Style = t_Doc.Styles.Item("Normal")
        t_Doc.Application.Selection.Font.Size = 10
        t_Doc.Application.Selection.TypeParagraph()
        t_Doc.Application.Selection.Font.Name = "Arial"
        ' t_WorkSheet.UsedRange.VerticalAlignment = Excel.XlVAlign.xlVAlignCenter
        ' t_WorkSheet.UsedRange.RowHeight = 20

        't_Doc.Application.Selection.ParagraphFormat.SpaceBefore = 0
        't_Doc.Application.Selection.ParagraphFormat.SpaceAfter = 0
        ' t_Doc.Application.Selection.ParagraphFormat.LineSpacing = 1

        '// COPY THE EXCEL AND PASTE IT INTO WORD!
        t_WorkSheet.UsedRange.Copy()

        t_Doc.Application.Selection.Paste()

        '// SIZE THE NEW TABLE TO BE 7 INCEHS WIDE.
        Dim t_WordGlobal As New Word.[Global]
        Dim t_Table As Word.Table
        t_Table = t_Doc.Tables.Item(t_Doc.Tables.Count)
        Dim UsableWidth As Single
        'Dim tlPanel As TableLayoutPanel
        'Dim aRow As Word.Row

        t_Table.Rows.SetLeftIndent( _
        LeftIndent:=0, RulerStyle:=Word.WdRulerStyle.wdAdjustNone)
        With t_Doc.PageSetup
            UsableWidth = .PageWidth - .LeftMargin - .RightMargin
        End With

        

        t_Table.PreferredWidth = UsableWidth
        t_Table.AllowAutoFit = True
        t_Table.Rows.SetHeight(0.43, Word.WdRowHeightRule.wdRowHeightExactly)

      

        'For Each aRow In t_Table.Rows
        '    styles.Add(aRow)
        'Next
        'For Each style As RowStyle In styles
        '    style.SizeType = SizeType.Absolute
        '    style.Height = 180
        'Next


        With t_Table
            On Error Resume Next

            .PreferredWidth = m_7InchWidth
            .Columns.Item(PG2A_NO).Width = t_WordGlobal.InchesToPoints(0.4)
            .Columns.Item(PG2A_NO).Cells.VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalBottom
            .Columns.Item(PG2A_NAME).Width = t_WordGlobal.InchesToPoints(2.6)
            .Columns.Item(PG2A_NAME).Cells.VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalBottom

            .Columns.Item(PG2A_NFIP).Width = t_WordGlobal.InchesToPoints(1)
            .Columns.Item(PG2A_REP).Width = t_WordGlobal.InchesToPoints(1)
            .Columns.Item(PG2A_DEP).Width = t_WordGlobal.InchesToPoints(1)
            .Columns.Item(PG2A_INS).Width = t_WordGlobal.InchesToPoints(1)

            'If t_Table.Rows.Count > 4 Then
            '    For x = 3 To (t_Table.Rows.Count - 1)
            '        t_Table.Rows.Item(x).Height = t_WordGlobal.InchesToPoints(0.25)
            '        t_Table.Rows.Item(x).HeightRule = Word.WdRowHeightRule.wdRowHeightExactly
            '        t_Table.Rows.Item(x).Cells.VerticalAlignment = Word.WdCellVerticalAlignment.wdCellAlignVerticalCenter
            '    Next

            '    t_Table.Rows.Item(1).AllowBreakAcrossPages = False
            '    t_Table.Rows.Item(2).AllowBreakAcrossPages = False
            '    t_Table.Rows.Item(1).HeadingFormat = True
            '    t_Table.Rows.Item(2).HeadingFormat = True
            'End If
Posted
Updated 25-May-14 5:58am
v2

1 solution

The code is not completed

the question is not clear
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900