473,666 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 "createobje ct" but I didn't get
anywhere.

Set shell = CreateObject("W Script.Shell")
Set fso = CreateObject("S cripting.FileSy stemObject")

Nov 13 '05 #1
2 12203
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("S cripting.FileSy stemObject")

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

set ts=Nothing
Set fs = Nothing
rcmail14...@yah oo.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 "createobje ct" but I didn't get
anywhere.

Set shell = CreateObject("W Script.Shell")
Set fso = CreateObject("S cripting.FileSy stemObject")


Nov 13 '05 #2
rc*********@yah oo.com wrote:
Set ts = fs.CreateTextFi le("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
24137
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 I'm not sure what changed. (I had applied ALL the W2K update patches... but... I'm not sure if the problem started before or after that.) Did any recent W2K patches change the way createObject, wScript.shell, or "NET SEND" works?
0
7095
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 website from an existing web host to our servers. This website used the WScript.Shell command to execute a series of Java commands that would send an encrypted email. I ran these commands directly on the server and they execute properly,
2
8478
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 like this: function runCommand(zmienna) { if (zmienna==-1) {
6
15631
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 setobjShell=Server.CreateObject("WScript.Shell"), I get the error VB err= 5,Invalid procedure call or argument
2
19272
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 folder.However if I am runing the file local it will work Any reason, why when the file is in the web server folder the create object failed to created the shell object. Systax:
0
2674
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 not. First Function Function try1 SET objShell = CreateObject("Wscript.Shell")
24
17451
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 System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
0
1337
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 files. I am able to create zip the file from if the source files are in local machine as well as if the files to be zipp are in other machines from the network. My code is as follow as
2
10477
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 " & url) strPResult = objCmd.StdOut.Readall() set objCmd = nothing: Set objWShell = nothing
0
8356
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8781
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8640
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4369
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
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 we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1776
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.