⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 IBM Lotus 123 操作程序例子
💻 FRM
📖 第 1 页 / 共 2 页
字号:
    
    Dim Myword      As Wordpro.Application
    Dim WPWordApp   As Wordpro.WPApplication
    Dim WordDoc     As Wordpro.TextDocument
    
    On Error Resume Next
    
    Set Myword = GetObject(, "WordPro.Application")
    
    If Err.Number <> 0 Then
        Err.Clear
        Set Myword = CreateObject("WordPro.Application")
    End If
    
    If Err.Number <> 0 Then
        MsgBox Err.Description, vbInformation
        Exit Sub
    End If
    
    On Error GoTo 0
    
    Set WPWordApp = Myword.Application
    WPWordApp.NewDocument
    Set WordDoc = WPWordApp.ActiveDocument
    
    Dim WordDivision As Wordpro.Division
    
    WPWordApp.Visible = True
    WordDoc.Activate
    
'    Call WPWordApp.NewDivision
    Set WordDivision = WPWordApp.Division
    
    

End Sub

Private Sub Command8_Click()
    Dim Myword As Wordpro.Application
    Dim NewDoc As Wordpro.Document
    Dim NewDocC As TextDocument
    Dim WPWordApp As Wordpro.WPApplication
    Dim NewObj As Worksheet
    Dim astr As String
    
    On Error Resume Next
    
    Set Myword = GetObject(, "WordPro.Application")
    
    If Err.Number <> 0 Then
        Err.Clear
        Set Myword = CreateObject("WordPro.Application")
    End If
    
    If Err.Number <> 0 Then
        MsgBox Err.Description, vbInformation
        Exit Sub
    End If
    
    On Error GoTo ErrHandle
    On Error GoTo 0
    
    '打开原有的文件
    Call Myword.OpenDocument(DocName:="Lotus.lwp", Location:="C:\Temp")
    
    Set WPWordApp = Myword.Application
    Set NewDocC = Myword.ActiveDocument
    WPWordApp.Visible = True
    NewDocC.Activate
        
    Dim strTemp As String
    Dim MyClickHere As String
    Dim GoToName  As String
    Dim stat As Integer
    '到指定书签位置
'    Call WPWordApp.GoToBookmark("TEST001")

    '到指定插入点位置
'    With WPWordApp
'        .Text.InsertText "This is some text which precedes the Click Here Block.  ", False
'        MyClickHere = .InsertClickHere()
'        .GoToClickHere (MyClickHere)
'    End With

    '到指定Division 位置
'    With WPWordApp
'        GoToName = InputBox("Type the name of the division you want to Go To:")
'        stat = .GoToDivision(GoToName)
'        If stat = 0 Then  ' the method failed
'            MsgBox "Couldn't find the division", vbOKOnly, "Example Script"
'        End If
'    End With
    
    '拷贝选择的段落并拷贝到剪贴板中
'    WPWordApp.SelectParagraph
'    WPWordApp.CopySelection
'    strTemp = Clipboard.GetText
'    MsgBox strTemp
    
    '创建平行列并到达指定列位置
'    With WPWordApp
'        .CreateParallelColumns 5, 2
'        .GotoNextParallelColumn
'    End With
    
   ' 创建一个5行5列的表格 , 并把光标定位到指定单元格
'    With WPWordApp
'        Dim MyTable As Table
'        .CreateTable False, "Default Table", 5, 5
'        Set MyTable = .Table
'        ' rows & cols are zero based
'        MyTable.CellLayout(1, 2).GoToLayout
'        MsgBox
'    End With
    
    '测试函数
'    If AssignCode() <> "" Then
'        MsgBox "You entered a valid code."
'    Else
'        MsgBox "The code you entered is not valid."
'    End If
    
    '插入文字且把部分分子粗体显示
'    With WPWordApp
'        .Text.InsertText "Now is the time for all good men to come to the aid of their party.  "
'        .Text.Font.Bold = True
'        .Text.InsertText "This is bolded text."
'        .Text.Font.Bold = False
'    End With
    '判断显示单元格的宽度
'    Dim TwipCellWid As Integer
'    With WPWordApp
'        .CreateTable
'        TwipCellWid = .Cell.Width
'        TwipCellWid = .CellRevert
'        Debug.Print "The cell width is " & TwipCellWid / 1440 & " inches."
'    End With
    
    'Example: CellRevert method

' This example creates a table with 5 columns and 5 rows then inserts text and
' changes the background color for row 1, column 0.  The background color is
' then reverted after the message box is closed.
' RUNTIME DEPENDENCIES: You must have a document open for this script to work.

'        Dim ExampleTable As Table
'        Dim ExampleCell As CellLayout
'
'        With WPWordApp
'            .CreateTable False, "Default Table", 5, 5
'            Set ExampleTable = .Table
'            ExampleTable.CellLayout(1, 0).GoToLayout
'
'            Set ExampleCell = ExampleTable.CellLayout(1, 0)
'            ExampleCell.Content.InsertText "Hello"
'            With ExampleCell.Background
'                .Pattern = 1
'                .Color.Red = 255
'                .Color.Blue = 194
'                .Color.Green = 255
'                .Color.Override = 2
'                .BackColor.Red = 65
'                .BackColor.Blue = 176
'                .BackColor.Green = 0
'            End With
'
'            MsgBox "Click OK to revert cell color change.", vbOKOnly, "Example Script"
'
'            .CellRevert
'        End With
        
        'Example: Content property
        'This example uses the ContentType property to print the type of content held in the focus to the LotusScript output panel.
'        Dim ContentsType As Integer
'        With WPWordApp
'            ContentsType = .Content.ContentType
'            Debug.Print ContentsType
'        End With

'        With WPWordApp
'            Debug.Print .Text.GetText(366, False)
'            Debug.Print .Text.GetText(368, False)
'            Debug.Print .Text.GetText(369, False)
'            While Not .Text.AtEndOfParagraph
'
'            Debug.Print .Text.GetText(366, True)
'            Wend
'        End With

        'Example: WordCount method
        'This example inserts some text into the current document, then
        'runs a word count.
'       With WPWordApp
'            .Text.InsertText "This is some sample text which will be used to test the word count method."
'            .WordCount
'       End With
       
     'Example: WordUnderline method
     ' This example toggles the word underline attribute of the selected text.
     ' RUNTIME DEPENDENCIES: You must have a document open and some text selected  ' for this script to work.
'    With WPWordApp
'        .WordUnderline
'        MsgBox "Click OK undo word underline change.", vbOKOnly, "Example Script"
'        .WordUnderline
'    End With
    
    
'Example: GetData method
' This example creates a dataset named 'ExampleDataSet' off of the active
' document. The 'FirstName' and 'LastName' items are created and filled with
' data. Finally the values for the dataset items are printed to the Script
' Editor Output panel.  Since no dataset item named 'Address' was defined, the
' default dataset value will be printed in the last statement.
' RUNTIME DEPENDENCIES: You must have a document open for this script to work.
'    With WPWordApp
'        Dim DataSetName As String
'
'        Dim DefValue As String
'        ' establish a variable representing all data sets in this document
'        Dim DocDataSets As WPDataSetCollection
'        Set DocDataSets = .ActiveDocument.WPDataSets
'
'        ' give a new name to the data set I'm creating
'        DataSetName = "ExampleDataSet"
'        DefValue = "Default"
'
'
'        ' assign values to new set
'
'        DocDataSets(DataSetName).SetData "FirstName", "John"
'        DocDataSets(DataSetName).SetData "LastName", "Doe"
'
'
'        ' retrieve values from set
'
'        Debug.Print DocDataSets(DataSetName).GetData("FirstName", DefValue)
'        Debug.Print DocDataSets(DataSetName).GetData("LastName", DefValue)
'        ' this will display default value, since address not defined.
'        Debug.Print DocDataSets(DataSetName).GetData("Address", DefValue)
'    End With

'    With WPWordApp
'        'Example: Underline method
'
'        ' This example first inserts sample text in the current document and selects
'        ' the paragraph. The script then uses the Underline method to toggle the
'        ' underline attribute.
'        ' RUNTIME DEPENDENCIES: You must have a document open with selected text
'        ' for this script to work.
'
'        .Text.InsertText "This is some sample text."
'        .SelectParagraph
'        .Underline
'    End With

'    With WPWordApp
'        'Example: TeamMail method
'
'        ' This example displays the Team Mail dialog box.
'        ' RUNTIME DEPENDENCIES: You must have a document open for this script to work.
'        .TeamMail
'    End With

'    With WPWordApp
'        'Example: StartFieldInsert method
'
'        ' This example creates a data file for the current document.  Two records are
'        ' added and the Merge bar is opened so to insert fields for merging.
'        ' RUNTIME DEPENDENCIES: You must have a document open for this script to work.
'
'        .CreateDataFile "~|", "Name~Address~City~State~Zip|", False, "C:\mergedat.lwp"
'
'        'Add some records to the virtual datafile
'        .MergeAddDataRecord "Jane Doe~100 Main St.~ Atlanta~ GA~30319|"
'        .MergeAddDataRecord "John Doe~100 Main St.~ Atlanta~ GA~30319|"
'
'        .StartFieldInsert
'    End With
'
'    With WPWordApp
'            'Example: StartEnvelopeDiv method
'
'            ' This example moves the insertion point to the beginning of the current
'            ' document and inserts sample address information.  A new envelope division is
'            ' created and an address prompt is inserted in the return address frame.
'            ' RUNTIME DEPENDENCIES: You must have a document open for this script to work.
'
'            .Text.MoveToStart 573
'            .Type "FirstName LastName[Enter]"
'            .Type "Address[Enter]"
'            .Type "City, State Zip[Enter]"
'
''            .StartEnvelopeDiv
'            .GoToLayout "Envelope:Envelope Return"
'
'            .Type "Return Address Goes Here[Enter]"
'    End With
    
    
'Example:     SplitDivision method
'This example displays divider tabs, then creates splits the current
'division at the insertion point.
'    With WPWordApp
'        .ActiveDocWindow.WinViewPrefs.IsViewSectionTabs = True
'        .SplitDivision
'    End With

'    With WPWordApp
'        'Example:  AcquireTWAINImage method
'        'This example launches your scanner software and attempts to scan
'        'an image.  If you do not have a scanner installed, an error message displays.
'        .AcquireTWAINImage
'    End With
'
'    With WPWordApp
'            .Text.InsertText "This is some sample text.  This will be an index entry. "
'            .Text.InsertText "This will be some more sample text.  And finally, another index entry."
'            ' add index entry with 'vice-versa' option selected
'
'            .AddIndexAllEntry "entry", "Index ""entry"" # ""index"" ", "Index ""index"" # ""entry"" "
'            'add just a plain entry to index all occurrences of 'sample'
'            .AddIndexAllEntry "sample", "Index ""sample"" # """" ", ""
'    End With
'    With WPWordApp
'            .Type "This is some text to be copied"
'            .SelectParagraph
'            .CopySelection
'            '    Forall ParaStyles In .AppFoundry.ParagraphStyles
'            '        Print ParaStyles.Name
'            '    End Forall
'    End With

'    With WPWordApp
'           'Example: BringFrameToFront method
'
'            ' This example creates two frames and changes the order of the layering
'            ' for the two frames.
'            ' RUNTIME DEPENDENCIES: You must have a document open for this script to work.
'
'            .NewFrame 3285, 1200, 1575, 1830
'            .Frame.Layout.Background.Color.Red = 82
'            .Frame.Layout.Background.Color.Blue = 239
'            .Frame.Layout.Background.Color.Green = 145
'            .Frame.Layout.Background.Color.Override = 2016
'            .Frame.Anchor 13, 156, 1666
'
'            .Deselect
'
'            .NewFrame 5285, 2200, 1575, 1830
'            .Frame.Layout.Background.Color.Red = 82
'            .Frame.Layout.Background.Color.Blue = 139
'            .Frame.Layout.Background.Color.Green = 45
'            .Frame.Layout.Background.Color.Override = 2016
'            .Frame.Anchor 13, 156, 1666
'
'            MsgBox "Click OK to send frame to back. ", vbOKOnly, "Example Script"
'            .SendFrameToBack
'
'            MsgBox "Click OK to bring frame to front. ", vbOKOnly, "Example Script"
'
'            .BringFrameToFront
'    End With
    
    
    With WPWordApp
'        .CloseAll 146
        .NewWindow
        MsgBox "Click OK to close the current window.", vbOKOnly, "Example Script"

        .CloseDocWindow
    End With
ErrHandle:
    If Err.Number <> 0 Then
        MsgBox Err.Description, vbInformation
    End If
End Sub


Function AssignCode() As String
            Dim code As String
            code$ = InputBox("Enter a 5-character code")
            If Len(code$) <> 5 Then Exit Function
                AssignCode = code$               ' It is a valid code.
End Function

Private Sub Command9_Click()
    Dim Myword As Wordpro.Application
    Dim NewDoc As Wordpro.Document
    Dim NewDocC As TextDocument
    Dim WPWordApp As Wordpro.WPApplication
    Dim astr As String
    
    On Error Resume Next
    
    Set Myword = GetObject(, "WordPro.Application")
    
    If Err.Number <> 0 Then
        Err.Clear
        Set Myword = CreateObject("WordPro.Application")
    End If
    
    If Err.Number <> 0 Then
        MsgBox Err.Description, vbInformation
        Exit Sub
    End If
    
    
    On Error GoTo 0
        '打开原有的文件
    Call Myword.OpenDocument(DocName:="Lotus.lwp", Location:="C:\Temp")
'
    Set WPWordApp = Myword.Application
    Set NewDocC = Myword.ActiveDocument
    WPWordApp.Visible = True
'    NewDocC.Activate

'   With WPWordApp
'        .NewWindow
'        MsgBox "Click OK to close the current window.", vbOKOnly, "Example Script"
'
'        .CloseDocWindow
'    End With
'
'    With WPWordApp
'        .CreateTable False, "Default Table", 5, 4
'        .SelectColumn
'        .ConnectCells
'    End With
    
'    With WPWordApp
'        .CreateTable False, "Default Table", 5, 4
'        .SelectRow
'        .ConnectRows
'    End With

'    Dim CurrentDivision As String
'    With WPWordApp
'        CurrentDivision = .Division.Name
'        ' copy it, then paste
'        .CopyDivision CurrentDivision
'        .PasteDivision CurrentDivision
'        'the copied division has the focus, so rename it.
'        .Division.DivisionInfo.Name = "Second copy"
'        MsgBox CurrentDivision, vbOKOnly, "Hopcom MIS"
'    End With

'    With WPWordApp
'        Dim SmartMaster As String
'        Dim NewDivId As String
'
'        SmartMaster = .ApplicationWindow.UserInterfacePrefs.StylePath & "\DEFAULT.MWP"
'        .CreateDivision SmartMaster, "", 185, "", ""
'    End With
    
    Dim i As Integer
    With WPWordApp
        For i = 1 To 10
            .Type "Now is the time for all good men to come to the aid of their country.  "
        Next
        .CreateDropCap 4, 3
        
        .Page.Layout.GoToLayout  ' return the insertion point to the page
    End With
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -