Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 94
Default VB Scrpit to input search results in Excel work book

I have the following vb script that uses the Excel object to search for files
containing a certain part number. I would like the search results to appear
in a new Excel workbook but if there is more than one file address returned I
only get one in the workbook.
--------------------------------------------------------------------------------
Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Workbooks.Add

dim partnum
partnum = Inputbox("Enter Part Number")
MsgBox(partnum)

Set objSearch = objExcel.FileSearch
objSearch.Lookin = "D:\"
objSearch.SearchSubfolders = TRUE
objSearch.FileName = "*.xls"
objSearch.TextOrProperty = partnum
objSearch.Execute

For Each strFile in objSearch.FoundFiles
objExcel.Cells(1, 1).Value = (strfile)
Next
MsgBox "Search Complete"
--------------------------------------------------------------------------------
Maybe I should be using a loop?? But I'm not sure how to go about it.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
work book on Excel 07 Beth Gaines New Users to Excel 4 November 9th 09 06:23 PM
Excel work book Helidriver Excel Worksheet Functions 1 May 1st 09 01:30 AM
excel work book Gerry Excel Discussion (Misc queries) 2 June 30th 08 03:04 PM
HOW TO MAKE A LIST OF WORK SHEET IN WORK BOOK IN EXCEL 2007 goutam Excel Programming 1 February 1st 08 07:40 AM
Save compared results to new work book grayham Excel Programming 1 July 5th 04 02:48 AM


All times are GMT +1. The time now is 10:44 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"