Foxtable(狐表)用户栏目专家坐堂 → 请教袍兄


  共有2452人关注过本帖平板打印复制链接

主题:请教袍兄

帅哥哟,离线,有人找我吗?
hbhb
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:狐神 帖子:5055 积分:13047 威望:0 精华:0 注册:2014/5/15 21:34:00
  发帖心情 Post By:2015/11/4 19:34:00 [只看该作者]

一天都没有找到,下面的代码还是不行,什么原因?好像有鬼?帮我看看?
Dim app As New MSWord.Application
try
    Dim doc = app.Documents.Open(tm)
    If app.ActiveWindow.Selection.Find.Execute("[" & bm & "附表]") Then
        '插入表格,方法12
        Dim dt2 As DataTable = dttable
        doc.Tables.Add(Range:=app.Selection.Range,NumRows:=1, NumColumns:= dt2.DataCols.Count)
        With app.Selection.Tables(1)
            .ApplyStyleHeadingRows = True
            .ApplyStyleLastRow = True
            .ApplyStyleFirstColumn = True
            .ApplyStyleLastColumn = True
            .Style = "网格型"
        End With
        For Each dc As DataCol In dt2.DataCols
            app.Selection.TypeText(Text:=dc.Name)
            Dim i As Double
            If Double.TryParse(dc.name,i)
                app.Selection.ParagraphFormat.Alignment = 2
            Else
                app.Selection.ParagraphFormat.Alignment = 1
            End If
            app.Selection.MoveRight(Unit:=12)
        Next
               For i As Integer = 0 To dt.rows.count-1
            Dim dr As Row = dt.rows(i)
          
                For j As Integer = 0 To dt.cols.count - 1
                    Dim dc As Col = dt.cols(j)
                    app.Selection.TypeText(Text:=dr(dc.Name))
                    Dim d As Double
                    If Double.TryParse(dr(dc.name),d)
                        app.Selection.ParagraphFormat.Alignment = 2
                    Else
                        app.Selection.ParagraphFormat.Alignment = 1
                    End If
                    If i = dt.rows.count-1 AndAlso j = dt.cols.count-1
                    Else
                        app.Selection.MoveRight(Unit:=12)
                    End If
                Next
            
        Next       
    End If 
    app.Documents(tm).save  
    app.quit
catch ex As exception
    app.Quit
finally
End try

 回到顶部
总数 14 1 2 下一页