473,395 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

alternative to WScript.Shell

I have seen some very general suggestions for alternative code to the
WScript.Shell code, but nothing specific. In the two lines of code
below (I think) the first line creates a text file on the hard drive.
When I get to this line I get runtime error 429 "ActiveX component
can't create object". I know I should not use WSH but I haven't been
able to figure out an alternative. I tried looking through the VBA
editor help file for "file" and "createobject" but I didn't get
anywhere.

Set shell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")

Nov 13 '05 #1
2 12155
Sorry, I wrote to soon. I found the code below and it does just what I
need.

Dim fs As Object
Dim ts As Object

Set fs = CreateObject("Scripting.FileSystemObject")

Set ts = fs.CreateTextFile("FileName", True)
ts.WriteLine "Text goes here."
ts.Close

set ts=Nothing
Set fs = Nothing
rcmail14...@yahoo.com wrote:
I have seen some very general suggestions for alternative code to the
WScript.Shell code, but nothing specific. In the two lines of code
below (I think) the first line creates a text file on the hard drive.
When I get to this line I get runtime error 429 "ActiveX component
can't create object". I know I should not use WSH but I haven't been
able to figure out an alternative. I tried looking through the VBA
editor help file for "file" and "createobject" but I didn't get
anywhere.

Set shell = CreateObject("WScript.Shell")
Set fso = CreateObject("Scripting.FileSystemObject")


Nov 13 '05 #2
rc*********@yahoo.com wrote:
Set ts = fs.CreateTextFile("FileName", True)
ts.WriteLine "Text goes here."
ts.Close


From the A97 online help.

When working with large amounts of data, it is often convenient to write data to or
read data from a file. The Open statement lets you create and access files directly.
Open provides three types of file access:

· Sequential access (Input, Output, and Append modes) is used for writing text
files, such as error logs and reports.
· Random access (Random mode) is used to read and write data to a file without
closing it. Random access files keep data in records, which makes it easy to locate
information quickly.
· Binary access (Binary mode) is used to read or write to any byte position in
a file, such as storing or displaying a bitmap image.

Note The Open statement should not be used to open an application's own file types.
For example, don't use Open to open a Word document, a Microsoft Excel spreadsheet,
or a Microsoft Access database. Doing so will cause loss of file integrity and file
corruption.

The following table shows the statements typically used when writing data to and
reading data from files.

Access Type Writing Data Reading Data
Sequential Print #, Write # Input #
Random Put Get
Binary Put Get

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Nov 13 '05 #3

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

Similar topics

5
by: Bill | last post by:
I used to be able to run the following ASP code on our corp machine (W2K Server Edition and IIS-5) and successfully send a net-msg to anyone on our intranet. Last week it stopped working... and...
0
by: Kyle | last post by:
To any who chose to provide an answer, or even any suggestions to this problem, I thank you greatly in advance. +200 pts. for any valid solutions. I am currently in the process of converting a...
2
by: Marcin Zmyslowski | last post by:
Hello all! I have installed MSDE on my local computer - Windows 2000 Professional. I have created a function which runs me a link whose path is placed in the input field. This function looks...
6
by: MacKenzie | last post by:
The statement in an asp page: dim objShell Set objShell = WScript.CreateObject("WScript.Shell") now gives this error: VB err= 424,Object required If I use...
2
by: Mike John | last post by:
I am trying to use the shell object to send keys to the explorer browser to run the send page funcion. I am receiving the above error only when I put my html file in the web server...
0
by: edurran | last post by:
Hi all, I have spent the last three days on this problem. Looked in many forums and not found the answer as yet. Hopefully ye can help. I have two functions. One works fine, the second does...
24
by: mdfidahussain | last post by:
hello frnds, I have written a simple asp .net code in button click event, in which should run "xx.cmd" file when pressed (below is the code) Partial Class _Default Inherits...
0
by: arunpatil84 | last post by:
Hi , I am working on one ASP.NET application which zips the document files and allow the user to download the files. For that I am using Izarc command line freeware utility to zip the...
2
by: =?Utf-8?B?VG9kZA==?= | last post by:
Hello I'm using the following script to try and ping: <% Response.Buffer = true %> <% url = "www.espn.com" Set objWShell = CreateObject("WScript.Shell") Set objCmd = objWShell.Exec("ping " &...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.