473,396 Members | 2,034 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Ms word file search in my computer

Expand|Select|Wrap|Line Numbers
  1. Private Sub CommandButton1_Click()
  2.  Dim fd As FileDialog
  3.  
  4.     Set fd = Application.FileDialog(msoFileDialogFolderPicker)
  5.  
  6.     fd.InitialFileName = ActiveWorkbook.Path
  7.     fd.Show
  8.  
  9.     On Error Resume Next
  10.  
  11.     jdcfwLogFilePath = fd.SelectedItems(1)
  12.  
  13.     If Err.Number <> 0 Then
  14.         Exit Sub
  15.     End If
  16.  
  17.     If jdcfwLogFilePath = "False" Then Exit Sub
  18.         DriveTextBox.Text = jdcfwLogFilePath
  19.  
  20. End Sub
  21.  
  22. Private Sub CommandButton2_Click()
  23. Dim i As Integer
  24. Dim myFile As String
  25. Dim endTerm As String
  26.      endTerm = FileNameTextBox.Text
  27.  Const wdFindContinue As Integer = 1
  28.  'checking textbox is empty
  29.  
  30. If FileNameTextBox.Text = "" Then
  31. MsgBox "Please Enter Keyword"
  32. Else
  33.  
  34. 'Search criteria
  35. With Application.FileSearch
  36.     .LookIn = DriveTextBox.Text 'path to look in
  37.     .FileType = msoFileTypeAllFiles
  38.     .SearchSubFolders = True
  39.     .TextOrProperty = "*" & endTerm & "*" 'Word to find in this line
  40.     .Execute 'start search
  41.  
  42. 'This loop will bring up a message box with the name of
  43. 'each file that meets the search criteria
  44.  
  45. Dim n As Integer
  46. n = 0
  47.     For i = 1 To .FoundFiles.Count
  48.  
  49.         ListBox1.AddItem (.FoundFiles(i))
  50.         n = n + 1
  51.     Next i
  52.  
  53. End With
  54. End If
  55. If n = 0 And FileNameTextBox.Text <> "" Then
  56. MsgBox ("Keyword Not found")
  57. End If
  58.  
  59. End Sub
  60.  
  61. Private Sub TextBox2_Change()
  62.  
  63. End Sub
  64.  
  65. Private Sub ListBox1_Click()
  66.  
  67. End Sub
  68.  
  69. Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
  70. Dim endTerm As String
  71.      endTerm = FileNameTextBox.Text
  72. Const wdFindContinue As Integer = 1
  73. 'MsgBox (ListBox1.Text)
  74.  Set wordApp = CreateObject("word.Application")
  75.  
  76.    wordApp.Documents.Open ListBox1.Text
  77.  
  78.     wordApp.Visible = True
  79.  
  80.     If Not IsMissing(endTerm) Then
  81.        With wordApp.Application.Selection.Find
  82.           .Text = endTerm
  83.           '<i>.HighlightColorIndex = wdYellow</i>
  84.           .Forward = True
  85.           .Wrap = wdFindContinue
  86.             .Format = False
  87.            .MatchCase = False
  88.            .MatchWholeWord = False
  89.            .MatchWildcards = False
  90.            .MatchSoundsLike = False
  91.           .MatchAllWordForms = False
  92.            .Execute
  93.  
  94.         End With
  95.    End If
  96.  
  97. End Sub
Feb 15 '13 #1
11 1983
I am having two text box. first text box i am entering the file name(d:\search)using the browse button.second text box i am entering the keyword(appication).it will automatically find the document files and list the listbox.if i am double clicking the list inside the search document means it will automatically open the word file and notify the keyword.
Now my doubt is fist text box i am giving the document file directly cant used for browser.How can i do.... If anybody known means plz help me
Feb 15 '13 #2
Rabbit
12,516 Expert Mod 8TB
I don't understand what your question is. Please try explaining again with a clearer and more concise statement.
Feb 15 '13 #3
Killer42
8,435 Expert 8TB
I've been trying really hard to understand the question. What I've worked out is that this is not VB6 code, but VBA. Presumably a Word macro.

If so, please post your question in the VBA forum, as you'll find much more expertise there.

Also, I'm afraid the question as originally posed is quite difficult to interpret. I gather it's something to do with the file/folder dialogue shown at line 7, and some sort of problem with either setting the starting folder or file name, or making use of the value that it returns. Can you please try to clarify? (Note: the word is "question", not "doubt").
Feb 19 '13 #4
Actually my project is to search a particular keyword from a file, under that key word few lines has to be retrieved "

steps:
Give a filename(ex.raja.doc)
Give a Keyword(ex.string)
Search the filename in whole computer(c:,d:...)
match the keyword.
if the keyword is found, retrieve few lines under the keyword from that file.
Actually i have done upto this

But the problem is table,
if the table presents under the keyword, then how can i retrieve that table.

Thanks
by
azhaguraju

im waiting for your reply
Feb 27 '13 #5
i have finished to search ms word files in folder only i want to search ms word files in directory(my computer)if anyone known means plz update
Feb 27 '13 #6
Rabbit
12,516 Expert Mod 8TB
Folder and directory are the same thing. I still don't know what you are trying to ask.
Feb 27 '13 #7
Actually my project is to search a particular keyword from a file, under that key word few lines has to be retrieved "

steps:
Give a filename(ex.raja.doc)
Give a Keyword(ex.string)
Search the filename in whole computer(c:,d:...)
match the keyword.
if the keyword is found, retrieve few lines under the keyword from that file.
Actually i have done upto this

But the problem is table,
if the table presents under the keyword, then how can i retrieve that table.
Rabbit Sir If you know means plz update soon
Feb 28 '13 #8
Rabbit
12,516 Expert Mod 8TB
You've already said all that. You have added no new information. I didn't understand what you were trying to ask the first time and I'm not going to understand it if you just keep repeating what you said.

Please rethink and rephrase your question in a different way.
Feb 28 '13 #9
my project is to search a particular keyword from a document file, under that key word few lines has to be retrieved "
if the keyword is found, retrieve few lines under the keyword from that file.i have done upto this

But if the table presents under the keyword, then how can i retrieve that table.
Can you give your mail id i will send screen shot .you can understand my question
Feb 28 '13 #10
[IMG]D:\azhaguraju\ht.bmp[/IMG]

we want to give a file name in file name text box(for example one.doc)
And we want enter the search keyword in keyword textbox.

if we press search button the function should search in all the directory(like C,D,E including sub folders)for the document have a name mention in the textbox.

if that document found. we have to find that document which contain that particular keyword.

if both condition are true. we have to add that file name with path in the listbox.
in vb 6.0

pls some one help me...thanks in advance....
Feb 28 '13 #11
Rabbit
12,516 Expert Mod 8TB
You keep saying the same stuff over and over. You keep mentioning a table and I have no idea what table you're talking about.

You can't attach an image from your computer like that. We won't be able to see it. You need to upload it first.

Also, please stop bumping your thread. It is against site policy.
Feb 28 '13 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: MouseHart | last post by:
I have a small program which lists my music files on my computer, but I can't get it to print exactly the way I want it to. The data is viewed in an MSFlexGrid named "TextGrid" and the following...
1
by: alikhome | last post by:
Hi! May be anybody knows... I want to open word file (or Excel) from IIS server (URL) without getting security window for input Username and password. I know Username, Password and Domain. I'm...
5
by: Daniel Walzenbach | last post by:
Hi, I need to know how I could populate a word file from within ASP.NET and stream it out to some user (I can rely on all users have at least Word XP installed). The preferable solution would be...
2
by: CopynPaste | last post by:
Hi, I wrote a VB.net program that import a text file, which I will parse and place into arrays. My question is how to open an existing Word file without the Dialog Box that has a 4x10 table and...
8
by: John Salerno | last post by:
I figured my first step is to install the win32 extension, which I did, but I can't seem to find any documentation for it. A couple of the links on Mark Hammond's site don't seem to work. ...
13
by: Ray Muforosky | last post by:
Hello all: Task: I want to do file search, using the "conatining text" option from a web page. How do I search for a file on my local drive containing a certain string, from a web page. That...
3
by: Robertico | last post by:
I'am new to php and have a question about a recursive file search. I'd like to do a recursive search for jpg-files and add the filenames (full path) to a mysql database. I appreciate any help ! ...
2
by: piola vago | last post by:
I'm making an application that monitor a particular file (not a directoy) and when trigger a change event it start a backup process of the changed file. I'm using FileSystemWatcher component. My...
11
by: sandeepkedlaya | last post by:
Hello, I need to copy images from a folder and copy to a word document. I have done as follows.. but It copies only last image. Can any one of you help me in this.. Private Sub Page_Load(ByVal...
2
by: shanmugamit | last post by:
hi, i have 2 lacks word file in that i want search the keyword from that word files. but i using file method it too much time to search data.any one give idea to search data good method like any...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.