ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Creating FileSystemObject (https://www.excelbanter.com/excel-programming/276530-creating-filesystemobject.html)

Kirk[_2_]

Creating FileSystemObject
 
I have the following code:

Public Function FolderExists(folderspec)
Dim fso As Object
Dim blnFolderExist As Boolean

Set fso = CreateObject("VBA.FileSystemObject")

If fso.FolderExists(folderspec) Then
MsgBox "Folder Exists"
Else
MsgBox "Folder Does Not Exist"
End If


End Function

I am attempting to verify that a folder path exists that
a user inputs.

I get a Run-time error '429': ActiveX componetn can't
create object.

I checked my references and the VBA Library exists with
FileSystem. I tried only FileSystem, but got the same
error.

I need to be able to verify that a path a user enters in
a UserForm exists. Am I on the right track? What do I
need to do to get the above code to work? Any help would
be appreciated. Thanks.


Kirk

Chip Pearson

Creating FileSystemObject
 
Kirk,

Change

Set fso = CreateObject("VBA.FileSystemObject")
to
Set fso = CreateObject("Scripting.FileSystemObject")



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com


"Kirk" wrote in message
...
I have the following code:

Public Function FolderExists(folderspec)
Dim fso As Object
Dim blnFolderExist As Boolean

Set fso = CreateObject("VBA.FileSystemObject")

If fso.FolderExists(folderspec) Then
MsgBox "Folder Exists"
Else
MsgBox "Folder Does Not Exist"
End If


End Function

I am attempting to verify that a folder path exists that
a user inputs.

I get a Run-time error '429': ActiveX componetn can't
create object.

I checked my references and the VBA Library exists with
FileSystem. I tried only FileSystem, but got the same
error.

I need to be able to verify that a path a user enters in
a UserForm exists. Am I on the right track? What do I
need to do to get the above code to work? Any help would
be appreciated. Thanks.


Kirk




Bob Phillips[_5_]

Creating FileSystemObject
 
Kirk,

FileSystemObject is part of Scripting not VBA. So use

Set fso = CreateObject("Scripting.FileSystemObject")


--

HTH

Bob Phillips

"Kirk" wrote in message
...
I have the following code:

Public Function FolderExists(folderspec)
Dim fso As Object
Dim blnFolderExist As Boolean

Set fso = CreateObject("VBA.FileSystemObject")

If fso.FolderExists(folderspec) Then
MsgBox "Folder Exists"
Else
MsgBox "Folder Does Not Exist"
End If


End Function

I am attempting to verify that a folder path exists that
a user inputs.

I get a Run-time error '429': ActiveX componetn can't
create object.

I checked my references and the VBA Library exists with
FileSystem. I tried only FileSystem, but got the same
error.

I need to be able to verify that a path a user enters in
a UserForm exists. Am I on the right track? What do I
need to do to get the above code to work? Any help would
be appreciated. Thanks.


Kirk





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

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