1. vb6.0 怎樣實現 word 的查找功能函數
這個不好實現。因為你用以自己的程序打不開Word文檔(它的格式只有Word能打開),給Word發送信息讓他查找的話,也沒有那樣的命令行參數。
你最好把Word文檔中的內容復制到你的程序文本框(例如Text1)中,輸入查找內容的文本框Text2,命名查找按鈕為Command1,然後代碼可以這樣寫:
Private Sub Command1_Click()
Dim i As Long
For i = Text1.SelStart + Text1.SelLength To Len(Text1.Text)
If Mid(Text1.Text, i + 1, Len(Text2.Text)) = Text2.Text Then
Text1.SetFocus
Text1.SelStart = i
Text1.SelLength = Len(Text2.Text)
Exit Sub
End If
Next
MsgBox "已搜索指定區域"
End Sub
'此功能是從游標處開始向下找的查找功能,找到後自動選定。
2. 如何用vb窗體界面查找並打開一個word文件,最好有vb工程實例
模糊查找?比較難哦。
打開文件倒是版簡單:權
PrivateDeclare Function ShellExecute Lib "shell32.dll" Alias _
"ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long
PrivateConst SW_SHOWNORMAL As Long = 1
PrivateConst SW_HIDE As Long = 0
'調用
Call ShellExecute(Me.hWnd, "Open", "c:\aaa.doc", vbNullString, _
vbNullString, SW_SHOWNORMAL)
3. vb獲取Word書簽的內容!並將其顯示在label控制項中!
VB中使用Label控制項,如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Label1.Text = "正在進行數據處理,請稍候..."
Dim bh1 As String
Dim xm1 As String
Dim zjls1, i, jb1, sj1, bj1, kg1, hx1, nf1, yf1, ts1 As Integer
Dim hxts1, kh1 As Double
Dim SQLString, Msg As String
SQLString = "SELECT bh As 編號,xm As 姓名,date8 As 日期 From kqsj WHERE month(date8) ='" & yf & "'"
Dim UserTable1 As DataTable = DBOperation.DBOperate(SQLString, Msg)
For i = 0 To UserTable1.Rows.Count
jb1 = jb1 + UserTable1.Rows(i).Item(4)
sj1 = sj1 + UserTable1.Rows(i).Item(5)
Next
Label1.Text = "數據處理完畢!"
End Sub
為什麼運行時,Label1.Text 中只有一個空框,不顯示 "正在進行數據處理,請稍候..."文字,而在程序運行快結束時Label1顯示 "數據處理完畢!
4. vb作業:利用文件系統控制項編寫一個Word文件查找顯示程序,程序運行界面如圖3-2 所示。跪求大神幫忙
只是忙著把妹么?這么簡單的作業也放上來---幾個簡單的控制項幾個簡單關聯----還讓我們這些網蟲活不?
5. vb中如何在word書簽處輸入文本
將Word中的指定位置設置書簽,在VB中給指定書簽復制
sub Test()
DIm strfilename as string
Dim strbookmarkname as string
dim strInfo as string
strfilename="C:\test.doc"
strbookmarkname="bkmTest"
strInfo="Test Bookmark OK"
set objDoc=CreateObject("word.application")
set objDoc=objApp.documents.open(strfilename)
objDoc.Bookmarks(strbookmarkname).range.text=strInfo
objDoc.save
objDoc.close 1
objApp.quit 0
end sub
這樣就可以了
6. vb 對word進行查找操作,如何對每個查到的字元串進行操作
Private Sub WWW1()
Dim sn As Variant, SS As String, I As Integer
Selection.WholeStory
SS = Selection.Text
sn = Split(SS, "*")
For I = 1 To UBound(sn)
sn(I) = Replace(sn(I), sn(I), Val(sn(I)) + 1)
SS = SS & vbCrLf & "T" & sn(I)
Next
Selection.TypeText Text:=SS
End Sub
7. 如何用VB製作一個程序,可以搜索Word中的內容
最簡單的做法回答,
Dim xWorkApp As Word.Application
Set xWorkApp = New Word.Application
dim xDoc as Word.Document
set xDoc = xWorkApp.ActiveDocument
xWorkApp.Selection.selectall
With xWorkApp.Selection.Find
.Forward = True
.ClearFormatting
.MatchWholeWord = True
.MatchCase = False
.Wrap = wdFindContinue
.Execute FindText:="Microsoft"
End With
8. VB 定位word書簽的問題!!!!
ActiveDocument這個對象不存在:為什麼這樣調用呢,從VBA例子中抄的嗎,在VBA和WORD共享進程,所以有ActiveDocument這個對象。
直接用NEWDOC調用。
If NewDoc.Bookmarks.Exists("name") =.....