View Single Post
 
Old 03-04-2024, 01:46 AM
gmaxey gmaxey is offline Windows 10 Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,601
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

ladracer,


"A" for effort. Thank you. While many think we are a free code writing service, our (or at least most of us) objective is to help you learn VBA. Your error message has told you one place you went wrong.


You declared strFolder as a string, and you set it's value to a string. A string variable is not a collection object. Instead of typing in the folder path, you can use the application folder picker:


Code:
  Dim oDlg as FileDialong

  Set oDlg = Application.FileDialog(msoFileDialogFolderPicker)
  If oDlg.Show <> -1 Then Exit Sub
  strFolder = oDlg.SelectedItems(1) & Application.PathSeparator

Again that is just going to return a string value e.g., "C:\My Files\My Batch Folder"


Now you need to iterate through and open each of .doc? files in the folder defined by that string. Look up and see what you find out about the Dir() function. There is your clue.


There will be other gotchas. You will need a row for each file in your folder. A "bevy" may not be enough. Instead of a "bevy" why not just one? Then in your code, as you iterate over each file, add a row. Also in your current code, you are always going to overwrite your data in row 2. You need to index that row number with each file processed.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote