Error Object Required Objfso
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this vbscript runtime error permission denied site About Us Learn more about Stack Overflow the company Business Learn vbscript runtime error object required more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x
800a01a8
Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up VBscript
Object Required Wscript
runtime error up vote 0 down vote favorite I have a VBScript that I am working on building. The script itself complets all of the functions within it - it throws an error only after the script ends. It is giving me the following error: vbscript runtime error: Object required 'objFSO' Here is the relavant function: Function ReadFileIntoArray (sFile) dim objFSO 'As FileSystemObject dim file dim volumes() Set file = objFSO.OpenTextFile(sFile) 'Error Thrown Here. do while not file.AtendOfStream redim preserve text(nlines) volumes(nlines) = file.Readline nlines = nlines + 1 loop file.close set file = nothing Set objFSO = nothing ReadFileIntoArray = volumes end Function The file is still opened and used properly. I'm a little lost. Any ideas? vbscript share|improve this question asked Dec 28 '10 at 20:27 Nutsy 111 add a comment| 3 Answers 3 active oldest votes up vote 3 down vote objFSO is never assigned a value. When the error occurs, objFSO's value is Empty, which is not an object. You're probably missing Set objFSO = CreateObject("Scripting.FileSystemObject") share|improve this answer edited Dec 28 '10 at 20:35 Joel Spolsky♦ 26.4k157095 answered Dec 28 '10 at 20:32 Thom Smith 9,7152857 Thanks for the response - I will test it now and let you know the results! –Nutsy Dec 28 '10 at 20:44 add a comment| up vote 0 down vote @Nutsy: @Thom Smith has the answer, I just think you might need to explicitly set how you wish to open the file as well though. I've updated your code to includ
a Question Need help? Post your question and get tips & solutions from a community of 418,536 IT Pros & Developers. It's quick & easy. 'object required' error using FileSystemObject P: n/a google I am trying to use the following ASP code to examine the file names in a folder: Dim fso, f, fl, s, fs Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.GetFolder("C:\Inetpub\wwwroot\MySite\subfolder ") Set fs = f.Files For Each fl in fs s = fl.Name 'Object Required error occurs here! Response.Write(s) Next Set fso = Nothing The asp page returns the 'Object Required' error on the line, "s = fl.Name". Why? Can anyone shed any light on this? Thanks Jul http://stackoverflow.com/questions/4549255/vbscript-runtime-error 28 '06 #1 Post Reply Share this Question 7 Replies P: n/a Janette For what it is worth, I have run this as both a stand alone vbscript and as an ASP page, and the only thing I changed was the path in the GetFolder command, and it worked fine for both. Both for a folder that did and didn't have contents. My only suggestions, are double check that you have the path correct and check https://bytes.com/topic/asp-classic/answers/516963-object-required-error-using-filesystemobject that you have appropriate permissions to the folder. Also it might be worth running this script as a vbscript ie take the code, put it in a file called xxxx.vbs, change response.write(s) to msgbox s, save and run it by double clicking. This may help identify if it is a permissions problem. Hope this helps Janette
get's the path of an exe. Now using Mid and InStr methods http://www.visualbasicscript.com/m81806-print.aspx I have fetched the folder path eg. "D:\\MainFolder" Then when a use the same path to create aSubFolder eg. "D:\\MainFolder\\SubFolder" it gives the ObjectRequired: http://www.ozgrid.com/forum/showthread.php?t=163255 "D:\\MainFolder\\SubFolder" error I have written code to ensure that the Main Folder exists. Where is the error, what extra is required Please object required please help. ehvbs Total Posts : 3355 Scores: 122 Reward points : 0 Joined: 6/22/2005Location: Germany Re:vbscript error 'Object Required' - Tuesday, March 23, 2010 11:11 PM 0 I suspect that you are missing a "Set" in an assignment statement. It would help if you'd post your error object required code and identify the line of the error. GeminiTwin Total Posts : 6 Scores: 0 Reward points : 0 Joined: 3/23/2010 Re:vbscript error 'Object Required' - Tuesday, March 23, 2010 11:27 PM 0 Here is the code: I have written a comment at the location where the error ocurs ... Option Explicit Dim oWS : Set oWS = CreateObject("WScript.Shell") Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject") Dim sSearchFor sSearchFor = "MySoftware.exe" If sSearchFor = "" Then Cleanup() Dim StartTime : StartTime = Timer Dim createFolder, sRegTmp, sOutTmp, eRegLine, iCnt, sRegKey, aRegFileLines, filesys, filetext, getname, path, colMatches, outnum, newfolder,filesys1,readthis,getpos, dPath, total,minus,reqpath,filetext1,str,getpos1,getpos2,getpos3,totalStrLen,LenUptoSlash,LenForMid,PathForDir,PathAsStr, PathAsStr1 set filesys = CreateObject("Scripting.FileSystemObject") set filesys1 = CreateObject("Scripting.FileSystemObject") '*** Create Folder ***' If filesys.FolderExists("C:\reg") Then filesys.DeleteFolder("C:\reg") End If newfolder = filesys.CreateFolder("C:\reg") set filetext = filesys.CreateTextFile ("C:\reg\Reg1.txt",2) path = filesys.GetAbsolutePathName("C:\reg\Reg1.txt") getname = filesys.GetFileName(path) sRegTmp = oWS.Environment("Process")("Temp") & "\RegTmp.tmp " oWS.Run "regedit /e /a " & sRegTmp, , T
Way | Trading Add-ins For Excel | Convert Excel Into Calculating Web Pages Excel Web Pages | Produce Clean Efficient VBA Code Every Time | Build Automated Trading Models In Excel | Excel Web Pages | Excel Video Training Forum New Posts FAQ Calendar Forum Actions Mark Forums Read Quick Links Today's Posts What's New? Advanced Search Forum HELP FORUMS Excel General Runtime error 424 object required. Excel Training / Excel Dashboards Reports If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. If you don't like Google AdSense in the posts, register or log in above. Click here to view the relaunched Ozgrid newsletter. Results 1 to 2 of 2 Thread: Runtime error 424 object required. Thread Tools Show Printable Version Search Thread Advanced Search March 12th, 2012 #1 veerusat View Profile View Forum Posts I agreed to these rules Join Date 11th March 2012 Posts 4 Runtime error 424 object required. Hi everyone plaese help me its urgent.....................When i tried to complile the following code i got an error saying" run time error 424 object required" VB: Dim objFSO As FileSystemObject Dim ts As TextStream Dim strText As String Dim strSearchText As String Dim strFileName As String Dim lngPos As Long Dim lngStringCount As Long strSearchText = "cb: hi" strFileName = CurrentProject.Path & "C:\Users\310314\Desktop\qwerty.txt" 'Create instance of FileSystemObject. Set objFSO = CreateObject("Scripting.FileSystemObject") Set ts = objFSO.OpenTextFile(strFileName, ForReading) 'Read entire contents of file, save to strText variable strText = ts.ReadAll lngPos = 1 Do lngPos = InStr(lngPos, strText, strSearchText) If lngPos > 0 Then lngStringCount = lngStringCount + 1 lngPos = lngPos + Len(strSearchText) End If Loop Until lngPos = 0 MsgBox "The String [