VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmMain
BorderStyle = 3 'Fixed Dialog
Caption = "Word文档字数统计"
ClientHeight = 2895
ClientLeft = 45
ClientTop = 330
ClientWidth = 5295
Icon = "frmMain.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2895
ScaleWidth = 5295
StartUpPosition = 3 '窗口缺省
Begin MSComDlg.CommonDialog dlgFile
Left = 3480
Top = 2160
_ExtentX = 847
_ExtentY = 847
_Version = 393216
CancelError = -1 'True
DefaultExt = "*.doc"
DialogTitle = "打开"
Filter = "Word文档(*.doc)|*.doc"
End
Begin VB.Frame Frame1
Caption = "Word文档"
Height = 1095
Left = 0
TabIndex = 3
Top = 0
Width = 5295
Begin VB.CommandButton cmdOpen
Caption = "打开(&O)..."
Height = 375
Left = 3840
TabIndex = 4
Top = 600
Width = 1335
End
Begin VB.Label lblFileName
BackColor = &H00FFFFFF&
BorderStyle = 1 'Fixed Single
Height = 255
Left = 120
TabIndex = 5
Top = 240
Width = 5055
End
End
Begin VB.Frame Frame3
Caption = "定位"
Height = 1695
Left = 0
TabIndex = 2
Top = 1200
Width = 1695
Begin VB.CommandButton cmdAddress
Caption = "定位"
Enabled = 0 'False
Height = 375
Left = 240
TabIndex = 10
Top = 1200
Width = 1215
End
Begin VB.TextBox txtHang
Alignment = 1 'Right Justify
Height = 270
Left = 840
MaxLength = 2
TabIndex = 9
Text = "2"
Top = 720
Width = 615
End
Begin VB.TextBox txtPage
Alignment = 1 'Right Justify
Height = 270
Left = 840
MaxLength = 2
TabIndex = 8
Text = "1"
Top = 360
Width = 615
End
Begin VB.CheckBox chkHang
Caption = "行"
Height = 255
Left = 240
TabIndex = 7
Top = 720
Value = 1 'Checked
Width = 495
End
Begin VB.CheckBox chkPage
Caption = "页"
Height = 255
Left = 240
TabIndex = 6
Top = 360
Value = 1 'Checked
Width = 495
End
End
Begin VB.Frame Frame2
Caption = "统计信息"
Height = 1695
Left = 1800
TabIndex = 0
Top = 1200
Width = 3495
Begin VB.ListBox lstCount
Height = 1320
Left = 120
TabIndex = 1
Top = 240
Width = 3255
End
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function SetWindowPos& Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Dim objWord As New Word.Application
Dim cDialog As Word.Dialog
Private Sub cmdAddress_Click()
If chkPage.Value And chkHang.Value Then
objWord.Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:=txtPage.Text
objWord.Selection.GoTo What:=wdGoToLine, Which:=wdGoToNext, Count:=txtHang.Text, Name:=""
Exit Sub
End If
If chkPage.Value Then
objWord.Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:=txtPage.Text
Exit Sub
End If
If chkHang.Value Then
objWord.Selection.GoTo What:=wdGoToLine, Which:=wdGoToFirst, Count:=txtHang.Text, Name:=""
End If
End Sub
Private Sub Form_Load()
Call SetWindowPos(Me.hwnd, -1, 0, 0, 0, 0, 3)
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
On Error Resume Next
objWord.Documents.Close
objWord.Quit
Set objWord = Nothing
End Sub