VBA Open multipal files
VBA Open multipal files
(OP)
I need to create a VBA file so that when a user ckicks a command button it will open ALL the files of a certin type in the directory (and sub folders) searches the files for a word or words and replaces it with what the user enters in a text box on the user form. Any ideas????\
Thanks
Thanks





RE: VBA Open multipal files
Declare 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
'To Use it
Dim hWnd As Long
Dim sFullPath As String
'sFullPath should contain the complete path and
'filename, including extension.
Call ShellExecute(hWnd, vbNullString, sFullPath, vbNullString, vbNullString, vbNormalFocus)
Let's say you are writing this in Excel VBA and want to open Excel files. I would not use the above, for you can do better using the Workbooks.Open method. If you can provide some more detail, there may be a better solution.
To do a recursive search through subdirectories, I would suggest going to the VB forum at tek-tips.com and do a search on the topic. You should look at using the FileSystemObject to retrieve a list of files of the particular type.
Hope that helps...
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.
RE: VBA Open multipal files
I need to open html files in a directory on a hard drive they are 4 folders deep with 1 or more html files in each directory going down, and replace a bit of imformation that is incorrect. there is 7 of such folders and maybe 200 or more total files to be fixed.
RE: VBA Open multipal files
DimensionalSolutions@Core.com
While I welcome e-mail messages, please post all thread activity in these forums for the benefit of all members.