CreateObject("Scripting.FileSystemObject") ?

M

MPM1100

This question is a repost and was also posted in General Questions....

I am having to go back to an Access 97 format. In the current project we use
the FileSystemObject to reference, parse, and do other essential file
manipulations.

When trying to create the object in 97, an error occurs, stating something
like "ActiveX component can't create object." Tried to set the only two
script references, Microsoft Script Control 1.0 and Microsoft Scriptlet, but
still get the error. Is this action even possible in 97?

Thanks in advance...
MPM
 
D

Douglas J. Steele

How have you declared the variable to which you're trying to assign the
results of the CreateObject call?

If you declare it As Object, it should work.
 
M

MPM1100

Doug,

Please feel free to see the other post where I responded to you there.
Answering this question... the declaration is a variant type...

Dim VarObj as Variant

Set VarObj = CreateObject("Scripting.FileSystemObject")

It is the set line that fails.
 
D

Douglas J. Steele

As I already said, it should be

Dim VarObj As Object

If it works in other versions of Access, it's a fluke. It shouldn't.
 
M

MPM1100

Hi Doug,

I beg to differ with you here. First, in 97 I have tried setting the
variable type to Object. The same result occurred. However, if you read the
help files regarding the use of the FSO, the example reads as such:

Sub ShowFileAccessInfo(filespec)
Dim fs, f, s
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFile(filespec)
s = f.Name & " on Drive " & UCase(f.Drive) & vbCrLf
s = s & "Created: " & f.DateCreated & vbCrLf
s = s & "Last Accessed: " & f.DateLastAccessed & vbCrLf
s = s & "Last Modified: " & f.DateLastModified
MsgBox s, 0, "File Access Info"
End Sub

The unspecified declaration in this example defaults to type Variant when
used. Apparently that is the intended method to be used.

So thanks anyway for your effort. The attempt is appreciated.
 
R

Robert Morley

Just to cover all the bases, are you using Access 97 on the same machine
you're using the 2000+ version of the code? I'm thinking that if it's a
different machine, perhaps FSO has been removed and/or disabled on that
machine. Network administrators will often lock down scripting to avoid the
spread of viruses.

The use of Variant vs. Object should make very little difference, other than
the fact that Object will be slightly faster and a little less bug-prone,
since it will know for certain that it IS an Object.

The fact that you mentioned not seeing "Microsoft Scripting Runtime" in your
references list makes me VERY suspicious that it has been locked down in
some fashion.


Rob
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top