ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pointing search function to "This Drive"? (https://www.excelbanter.com/excel-programming/279765-pointing-search-function-drive.html)

Ed[_9_]

Pointing search function to "This Drive"?
 
I burn a set of files - an Excel workbook and several Word documents - to a
CD. All the files are in the same folder. I have hyperlinks in the
workbook to the Word docs that work fine, no matter what the CD drive letter
of the individual computer is.

But I also have a search function that returns the names of documents
matching the search criteria. It works fine on my computer, and fine on a
network drive. But I'm having trouble telling the function to look at "this
folder" on whatever drive it happens to be on. If anyone has suggestions, I
would appreciate it. The relevant parts of the code a

Dim strLocation As String
strLocation = "This Folder"

strName = Range("D3").Text

With Application.FileSearch
.NewSearch
.LookIn = strLocation
.SearchSubFolders = False
.TextOrProperty = strSearchFor
.Filename = "L5-" & strName & "*.doc"
.Execute

TIA
Ed



Tom Ogilvy

Pointing search function to "This Drive"?
 
It isn't clear what "this folder" is supposed to refer to. If it is the
folder where the file with the code resides, then use

strLocation = Thisworkbook.Path

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
I burn a set of files - an Excel workbook and several Word documents - to

a
CD. All the files are in the same folder. I have hyperlinks in the
workbook to the Word docs that work fine, no matter what the CD drive

letter
of the individual computer is.

But I also have a search function that returns the names of documents
matching the search criteria. It works fine on my computer, and fine on a
network drive. But I'm having trouble telling the function to look at

"this
folder" on whatever drive it happens to be on. If anyone has suggestions,

I
would appreciate it. The relevant parts of the code a

Dim strLocation As String
strLocation = "This Folder"

strName = Range("D3").Text

With Application.FileSearch
.NewSearch
.LookIn = strLocation
.SearchSubFolders = False
.TextOrProperty = strSearchFor
.Filename = "L5-" & strName & "*.doc"
.Execute

TIA
Ed





Ed[_9_]

Pointing search function to "This Drive"?
 
That was it, Tom. Thank you once again.

Ed

"Tom Ogilvy" wrote in message
...
It isn't clear what "this folder" is supposed to refer to. If it is the
folder where the file with the code resides, then use

strLocation = Thisworkbook.Path

--
Regards,
Tom Ogilvy

"Ed" wrote in message
...
I burn a set of files - an Excel workbook and several Word documents -

to
a
CD. All the files are in the same folder. I have hyperlinks in the
workbook to the Word docs that work fine, no matter what the CD drive

letter
of the individual computer is.

But I also have a search function that returns the names of documents
matching the search criteria. It works fine on my computer, and fine on

a
network drive. But I'm having trouble telling the function to look at

"this
folder" on whatever drive it happens to be on. If anyone has

suggestions,
I
would appreciate it. The relevant parts of the code a

Dim strLocation As String
strLocation = "This Folder"

strName = Range("D3").Text

With Application.FileSearch
.NewSearch
.LookIn = strLocation
.SearchSubFolders = False
.TextOrProperty = strSearchFor
.Filename = "L5-" & strName & "*.doc"
.Execute

TIA
Ed








All times are GMT +1. The time now is 05:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com