LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Need help with Array with type, invalid qualifier & runtime error

Ok. Not sure what I am doing wrong so i will start off with what I want to do.
Below is my code that is to go out to location of workbook, look for other
workbooks saved in subfolders,save their location, then manager's name, and
year from the file name to an array. ex location: C:\Documents and
Settings\Guest\Desktop\cand be deleted\2008 CBT Tracker for DoeJane.xls

Problems:
1 I am getting an complier error for line starting off
"ListbManagerNameSelection". It is for the array. I was trying to make it
global because I will reuse them on another part of the workbook.
I removed that part out to make sure the rest would work but when it
attempts to save data to the first array i receive run time error 424. what
am i doing wrong?

Private Sub UserForm_Activate()

If (NumFiles = LoadFileDate(CBTfilesArray)) = True Then ' Goes to This
Workbook code screen and loads manger name, year, file path\name

For count = 1 To NumFiles
ListbManagerNameSelection.List = CBTfilesArray.ManagerName
'Output manager's name in list box to be selected by user
Next count

Else

MsgBox "There were no files found."

End If

End Sub



'Code below is saved in Module
Option Explicit
Public CBTfilesArray() As Variant
Type CBTfilesArray
ManagerName As String
CBTtrackingYear As Integer
CBTtrackerFileName As String
End Type
Function LoadFileDate()
Dim fs As Object
Dim i As Integer
Dim Mypath As String



Mypath = ActiveWorkbook.Path
Set fs = Application.FileSearch
MsgBox Mypath

With fs
'Change below to give the name of the Directory you want to search
.LookIn = Mypath & "\"
.SearchSubFolders = True
.FileName = "*.xls"

If .Execute() 0 Then

For i = 1 To .FoundFiles.count

ReDim Preserve CBTfilesArray(i - 1)

CBTfilesArray(i - 1).ManagerName = Mid(.FoundFiles(i),
InStrRev(.FoundFiles(i), " ") + 1) 'Get Manager Name and adds it to array
CBTfilesArray(i - 1).CBTtrackingYear = (Mid(.FoundFiles(i),
InStrRev(.FoundFiles(i), "\") + 1, 4)) ' Get the year of the CTB Tracker
CBTfilesArray(i - 1).FileName = (.FoundFiles(i)) 'Get file
address and addes to array


Next i

LoadFileDate = .FoundFiles.count
Else
LoadFileDate = False
End If

End With

If LoadFileDate Then
MsgBox (LoadFileDate + 1) & " files found. Managers are " &
CBTfilesArray(1).ManagerName
Else
MsgBox "No files were loaded into Array"
End If
End Function
 
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
Invalid qualifier error in macro orquidea Excel Discussion (Misc queries) 0 December 19th 07 06:18 PM
compile error: invalid qualifier. MGG Excel Programming 3 August 2nd 05 04:10 PM
Runtime Error 381 Couldn't set list property, invalid array index Newbillian Excel Programming 2 June 17th 04 11:25 AM
Runtime Error 381 Couldn't set list property, invalid array index Newbillian Excel Programming 0 June 16th 04 11:28 PM


All times are GMT +1. The time now is 06:48 AM.

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

About Us

"It's about Microsoft Excel"