| re: Help - runtime error 91 - object variable not set
Peter wrote:[color=blue]
> I have a program which was working fine.
> In it a function works out the number of .jpg files in a specified folder.
> I then realised that I needed to make sure the folder exists first & added
> the code for this.
> After this I get the Runtime Error 91 - Object variable not set.
> I've rem'd out my added code to no avail. Tried rebooting to.
> The earlier exe version of the program continues to work OK.
> The code in question is shown below. I'd appriciate any advice on how I've
> messed this up & how to fix it
> I'm running VB6 on XP pro SP2
> mstrFolder is declared at the module level and Quickwatch shows it's
> contents are a valid path.
>
> many thanks
>
>[/color]
Dim objFSO As Object, objFolder As Object
Dim objFiles As Object, objFile As Object
Set objFolder = objFSO.GetFolder(mstrFolder) ' ---- The error occurs at
this line ---
So that's where it occurs. objFSO is not set and is still Nothing.
Therefore, it does not have a GetFolder method and raises an error.
I don't know why you are using late binding, but you can set objFSO to a
filesystem object by using the new keyword or the CreateObject function.
Best regards |