Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works

why won't my vbscript work?

  • Please log in to reply



    New Member

  • Member
  • Pip
  • 1 posts
Hi. I'm a complete newbie in vbscript, and I actually do not intend to learn a lot of it, unless I really need. I am developing an application that runs an html file offline. I need this html file to get the content of a txt file, transform each line of this text into a variable that javascript can handle and send this value to a flash file loaded in the same html. The only part I can work out succesfuly is the one of sending a js variable to a flash file. To do the rest I'm trying to use a vbscript code that reads the content of an external text file and send to an html 'select' object (I don't know if object is the term). However it fails everytime I run the html outside the desktop directory. By desktop directory I mean 'C:\Users\Nakkao\Desktop'. If the html is not located there it won't work. Why?

My code is:

<script Language="VBScript">

sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")

	Sub Window_OnLoad
		ForReading = 1
		Set objFSO = CreateObject("Scripting.FileSystemObject")
		Set objFile = objFSO.OpenTextFile _
			(sCurPath+"\lol.txt", ForReading)
		Do Until objFile.AtEndOfStream
			strLine = objFile.ReadLine
			Set objOption = Document.createElement("OPTION")
			objOption.Text = strLine
			objOption.Value = strLine
	End Sub

	<select size="5" name="FileContent" style="width:250"></select>


  • 0





  • Member
  • PipPip
  • 53 posts
EDIT: Never mind, didn't read your code fully...

sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")

In that line, try replacing the period with your C drive, and see if it will run there. New line to copy:

sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName("C:\")

Then try putting a file in your C drive, and not your Desktop, and it might work. You can modify the path accordingly.

A path is complete and unambiguous if it provides a complete reference from the root of the specified drive. A complete path can only end with a path separator character (\) if it specifies the root folder of a mapped drive.

- Quoted from MSDN

Edited by xBPM07x, 27 January 2009 - 10:23 PM.

  • 0

Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP