473,498 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File system error

Hi

I am getting the 'User defined type not defined' on the line;

Dim fso As Scripting.FileSystemObject.

What am I doing wrong? What reference do I need to add? Do I need to
install/enable scripting on the win xp sp2 machine?

Thanks

Regards

Jan 15 '06 #1
4 6053
John wrote in message <OL**************@TK2MSFTNGP11.phx.gbl> :
Hi

I am getting the 'User defined type not defined' on the line;

Dim fso As Scripting.FileSystemObject.

What am I doing wrong? What reference do I need to add? Do I need to
install/enable scripting on the win xp sp2 machine?

Thanks

Regards


The reference, I think, is Microsoft Scripting Runtime (in VBE - Tools
|
References), or try late binding.

--
Roy-Vidar
Jan 15 '06 #2
"RoyVidar" <ro*************@yahoo.no> wrote in message
news:mn***********************@yahoo.no...
John wrote in message <OL**************@TK2MSFTNGP11.phx.gbl> :
Hi

I am getting the 'User defined type not defined' on the line;

Dim fso As Scripting.FileSystemObject.

What am I doing wrong? What reference do I need to add? Do I need to
install/enable scripting on the win xp sp2 machine?

Thanks

Regards


The reference, I think, is Microsoft Scripting Runtime (in VBE - Tools |
References), or try late binding.


To use Late Binding (which would be my vote if you have to use FSO), you'd
use

Dim fso As Object

Set fso = CreateObject("Scripting.FileSystemObject")

Note that when you use Late Binding, any intrinsic constants defined by the
Scripting library are unavailable to you: you either need to define the
constants yourself, or replace them by the actual value of the constant. For
example, you couldn't use:

Dim fso As Object
Dim f As Object
Dim ts As Object

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile("test1.txt")
Set ts = f.OpenAsTextStream(ForWriting, TristateUseDefault)

You'd either have to include a line:

Const ForWriting = 2, TristateUseDefault = -2

or rewrite the code as

Dim fso As Object
Dim f As Object
Dim ts As Object

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile("test1.txt")
Set ts = f.OpenAsTextStream(2, -2)

Are you sure, though, that you need FSO? There's extremely little that FSO
can do that you can't already do in VBA.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

Jan 15 '06 #3
I am just trying to read an html file from disk.

Thanks

Regards

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
"RoyVidar" <ro*************@yahoo.no> wrote in message
news:mn***********************@yahoo.no...
John wrote in message <OL**************@TK2MSFTNGP11.phx.gbl> :
Hi

I am getting the 'User defined type not defined' on the line;

Dim fso As Scripting.FileSystemObject.

What am I doing wrong? What reference do I need to add? Do I need to
install/enable scripting on the win xp sp2 machine?

Thanks

Regards


The reference, I think, is Microsoft Scripting Runtime (in VBE - Tools |
References), or try late binding.


To use Late Binding (which would be my vote if you have to use FSO), you'd
use

Dim fso As Object

Set fso = CreateObject("Scripting.FileSystemObject")

Note that when you use Late Binding, any intrinsic constants defined by
the Scripting library are unavailable to you: you either need to define
the constants yourself, or replace them by the actual value of the
constant. For example, you couldn't use:

Dim fso As Object
Dim f As Object
Dim ts As Object

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile("test1.txt")
Set ts = f.OpenAsTextStream(ForWriting, TristateUseDefault)

You'd either have to include a line:

Const ForWriting = 2, TristateUseDefault = -2

or rewrite the code as

Dim fso As Object
Dim f As Object
Dim ts As Object

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile("test1.txt")
Set ts = f.OpenAsTextStream(2, -2)

Are you sure, though, that you need FSO? There's extremely little that FSO
can do that you can't already do in VBA.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

Jan 15 '06 #4
No reason for FSO then. The following VBA code will read a file line by line
into variable strBuffer.

Dim intFile As Integer
Dim strBuffer As String
Dim strFile As String

strFile = "C:\My Folder\MyFile.html"

intFile = FreeFile()
Open strFile for Input As #intFile
Do While Not EOF(intFile)
Line Input #intFile, strBuffer
' strBuffer now contains a line of data: work with it

Loop

Close #intFile

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
"John" <Jo**@nospam.infovis.co.uk> wrote in message
news:Wa********************@pipex.net...
I am just trying to read an html file from disk.

Thanks

Regards

"Douglas J. Steele" <NOSPAM_djsteele@NOSPAM_canada.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
"RoyVidar" <ro*************@yahoo.no> wrote in message
news:mn***********************@yahoo.no...
John wrote in message <OL**************@TK2MSFTNGP11.phx.gbl> :
Hi

I am getting the 'User defined type not defined' on the line;

Dim fso As Scripting.FileSystemObject.

What am I doing wrong? What reference do I need to add? Do I need to
install/enable scripting on the win xp sp2 machine?

Thanks

Regards

The reference, I think, is Microsoft Scripting Runtime (in VBE - Tools |
References), or try late binding.


To use Late Binding (which would be my vote if you have to use FSO),
you'd use

Dim fso As Object

Set fso = CreateObject("Scripting.FileSystemObject")

Note that when you use Late Binding, any intrinsic constants defined by
the Scripting library are unavailable to you: you either need to define
the constants yourself, or replace them by the actual value of the
constant. For example, you couldn't use:

Dim fso As Object
Dim f As Object
Dim ts As Object

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile("test1.txt")
Set ts = f.OpenAsTextStream(ForWriting, TristateUseDefault)

You'd either have to include a line:

Const ForWriting = 2, TristateUseDefault = -2

or rewrite the code as

Dim fso As Object
Dim f As Object
Dim ts As Object

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFile("test1.txt")
Set ts = f.OpenAsTextStream(2, -2)

Are you sure, though, that you need FSO? There's extremely little that
FSO can do that you can't already do in VBA.
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


Jan 15 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
16596
by: o'seally | last post by:
solaris/linux admins/rookie_developers that battle with this error are probably all frustrated when it happens. i bet you're also somehow frustrated by this seemingly unsolvable error :-) ...take...
2
3913
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
11
3051
by: Skc | last post by:
I have a .txt which has been exported as a .csv from an external source. What i need to do is to import this into SQL2000 (into a table) but I need to do special things on the data: 1. I need to...
3
12155
by: Michael Bøcker-Larsen | last post by:
Hi I'v been stuck on this problem for ages now. I have found that I'm not the only one with this problem, by looking through the different newsgroups. Hope you can help me! I know there is a...
13
4281
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
2
2638
by: Anna | last post by:
I added a small Web.Config file to the root of my website so that I could view errors on a machine other than the server: <configuration> <system.web> <customErrors mode="Off" /> </system.web>...
6
4119
by: tshad | last post by:
I have an upload file input as: <input id="MyFile" style="width:300px" type="File" runat="Server"> This works fine, but I find that if my page doesn't pass validation during postback, the page...
8
9695
by: Sarah | last post by:
I need to access some data on a server. I can access it directly using UNC (i.e. \\ComputerName\ShareName\Path\FileName) or using a mapped network drive resource (S:\Path\FileName). Here is my...
1
5682
by: hamil | last post by:
I am trying to print a graphic file (tif) and also use the PrintPreview control, the PageSetup control, and the Print dialog control. The code attached is a concatination of two examples taken out...
2
151624
by: antonyliu2002 | last post by:
I am testing AJAX. I've downloaded the AJAX Extension and the CTP December package and installed on BOTH my development machine and the production server. Then I created a very very simple web...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7002
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7165
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7203
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
4908
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1417
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.