以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  如何将代码改写为ft可用的?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=116285)

--  作者:kgdce
--  发布时间:2018/3/22 11:17:00
--  如何将代码改写为ft可用的?
    Dim app As New MSWord.Application
    try
        Dim doc = app.Documents.add
        With Doc.PageSetup
            .Orientation = 1 \'页面方向:wdOrientPortrait--纵向,wdOrientLandscape--横向
            \'.PageWidth = MSWord.CentimetersToPoints(21) \'纸张宽21cm
            \'.PageHeight =MSWord.CentimetersToPoints(29.7) \'纸张高29.7cm
            \'.TopMargin = MSWord.CentimetersToPoints(2) \'上边距2cm
            \'.BottomMargin = MSWord.CentimetersToPoints(1.5) \'下边距1.5cm
            \'.LeftMargin = MSWord.CentimetersToPoints(2.5) \'左边距2.5cm
            \'.RightMargin = MSWord.CentimetersToPoints(1.5) \'右边距1.5cm
        End With
这是word vba中可用的,但在ft中不能执行,请问如何改写才能执行。

--  作者:有点甜
--  发布时间:2018/3/22 11:27:00
--  

代码这样写

 

Dim app As New MSWord.Application
try
    Dim doc = app.Documents.add
    With Doc.PageSetup
        .Orientation = 1 \'页面方向:wdOrientPortrait--纵向,wdOrientLandscape--横向
        .PageWidth = app.CentimetersToPoints(21) \'纸张宽21cm
        .PageHeight = app.CentimetersToPoints(29.7) \'纸张高29.7cm
        .TopMargin = app.CentimetersToPoints(2) \'上边距2cm
        .BottomMargin = app.CentimetersToPoints(1.5) \'下边距1.5cm
        .LeftMargin = app.CentimetersToPoints(2.5) \'左边距2.5cm
        .RightMargin = app.CentimetersToPoints(1.5) \'右边距1.5cm
    End With

catch ex As exception
    msgbox(ex.message)
End try