Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help Needed

Status
Not open for further replies.

mixmaster1

Technical User
Feb 10, 2014
2
0
0
GB
Hi All

Trying to get this to write to a Text file but keeps giving me an error "path not pound" line 22 Char 1

Any help you can give would be greatly appreciated..

Code:
<html>
<head>


<script language="vbscript">
Sub ndhta
Set objShell = CreateObject("WScript.Shell")
objShell.Run("2ndhta.hta")
window.close "close this HTA"
End Sub
</script>

<script language="vbscript">
Sub SaveData
Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists("C:\Scripts\Test.tsv") Then
Set objFile = objFSO.OpenTextFile("C:\Scripts\Test.tsv",8)
strLine = Aud.Value & vbTab & AFM.Value & vbTab & Hod.Value & vbTab & Van.Value & vbTab & Acc.Value & vbTab & Job.Value & vbTab & Work.Value & vbTab & DWC.Value & vbTab & Tech.Value & vbTab & TechId.Value & vbTab & Cust.Value & vbTab & Post.Value
objFile.WriteLine strLine
objFile.Close
             Else
Set objFile = objFSO.CreateTextFile("C:\Scripts\Test.tsv")
strLine = Aud.Value & vbTab & AFM.Value & vbTab & Hod.Value & vbTab & Van.Value & vbTab & Acc.Value & vbTab & Job.Value & vbTab & Work.Value & vbTab & DWC.Value& vbTab & Tech.Value & vbTab & TechId.Value & vbTab & Cust.Value & vbTab & Post.Value
objFile.WriteLine strLine
objFile.Close
             End If
         End Sub

</script>


<HTA:APPLICATION
  APPLICATIONNAME="Live Audit HTA"
  	SYSMENU="yes"
	border="thin"
	borderstyle="raised"
	maximizebutton="no"
	minimizebutton="no"
	scroll="no"	
	version="1.0"
>


<title>Audit Information</title>

<link rel="stylesheet" type="text/css" href="style.css">
<style type="text/css">

<style type="text/css">
  body {background-color:#FFFFFF;}
  p {font:bold 18px arial;}
</style>

</head>

<script language="javascript">
window.moveTo(0,0);
window.resizeTo(screen.width,screen.height);
</script>


<Body>




<form>

<div id="footer" style="background-color:#FFA500;clear:both;text-align:center;">
Field Technician Live Audit</div><BR><BR><BR><BR><BR>


<img style= "position:absolute; top: 40px; Left:950px; width:150px; height:90px" src="qual.jpg">


<table border="5" style="z-index: 1; position: inline; width: 1120px; height: 10px; left: 0px; top: 100px;" width="500" ; align = center>
                <tbody>

<tr align="center" valign="top">
                        <td scope="col"><strong>Auditors Name:&nbsp;<br /></strong></td>
                        <td><input id="Aud" maxlength="55" name="Aud" size="35" type="text" /></td>

                    </tr>

<tr align="center" valign="top">
                        <td scope="col"><strong>AFM:&nbsp;<br/></strong></td>
                        <td><input id="AFM" maxlength="55" name="AFM" size="35" type="text" /></td>

                    </tr>
<tr align="center" valign="top">
                        <td scope="col"><strong>HOD Region:&nbsp;<br/></strong></td>
                        <td><input id="Hod" maxlength="55" name="Hod" size="35" type="text" /></td>

                    </tr>

<tr align="center" valign="top">
                        <td scope="col"><strong>Vehicle Registration:&nbsp;<br/></strong></td>
                        <td><input id="VAN" maxlength="55" name="Van" size="35" type="text" /></td>

                    </tr>
<tr align="center" valign="top">
                        <td scope="col"><strong>Account Number:&nbsp;<br/></strong></td>
                        <td><input id="ACC" maxlength="55" name="ACC" size="35" type="text" /></td>

                    </tr>

<tr align="center" valign="top">
                        <td scope="col"><strong>Job Characteristics:&nbsp;<br/></strong></td>
                        <td><input id="Job" maxlength="55" name="Job" size="35" type="text" /></td>

                    </tr>
<tr align="center" valign="top">
                        <td scope="col"><strong>Work Undertaken:&nbsp;<br/></strong></td>
                        <td><input id="Work" maxlength="55" name="Work" size="35" type="text" /></td>

                    </tr>
<tr align="center" valign="top">
                        <td scope="col"><strong>Date Work Completed:&nbsp;<br/></strong></td>
                        <td><input id="DWC" maxlength="55" name="DWC" size="35" type="text" /></td>

                    </tr>
<tr align="center" valign="top">
                        <td scope="col"><strong>Technician Name:&nbsp;<br/></strong></td>
                        <td><input id="Tech" maxlength="55" name="Tech" size="35" type="text" /></td>

                    </tr>

<tr align="center" valign="top">
                        <td scope="col"><strong>Technician ID:&nbsp;<br/></strong></td>
                        <td><input id="TechId" maxlength="55" name="TechId" size="35" type="text" /></td>

                    </tr>
<tr align="center" valign="top">
                        <td scope="col"><strong>Customer Address:&nbsp;<br/></strong></td>
                        <td><input id="Cust" maxlength="55" name="Cust" size="35" type="text" /></td>

                    </tr>
<tr align="center" valign="top">
                        <td scope="col"><strong>Post Code:&nbsp;<br/></strong></td>
                        <td><input id="Post" maxlength="55" name="Post" size="35" type="text" /></td>

                    </tr>

            </tr>

   </tr>
                </tbody>
            </table><BR><BR>

<table width="100%">
  <tbody>
<tr align="center" valign="top">

                        
                        <td><input type="button" value="Save" name="save_button"  onClick="SaveData"><p></p></td>

                    </tr>

   </tr>
                </tbody>
            </table>

<div style="position:  absolute;  bottom:  0;">
<input type="button" value="Continue" name="continue_button"  onClick="ndHta"><p></p></div>



</form>
<SPAN class=sig><font color="#ff0000">
Developed By Alfredo Parducci - Virgin Media - 2014.</font>
</SPAN>

</body>
</html>
 
You're trying to create a text file (if none exists) but the "path not found" error probably means the 'Scripts' folder doesn't exist and needs to be tested for and created first.

Hope this helps...
 
CreateTextFile will not create a non-existing path. So if the path you are trying to create a file in does not exist you will get the error that you are describing. I anticipate that you may see further errors once you fix this, caused by .Value
 
Hi Rick, Thanks for the swift reply.. Even when i create the folder manually and a test file it still gaives same error?
 
I used the following as a test:

Code:
Set objFSO = CreateObject("Scripting.FileSystemObject")
If Not objFSO.FolderExists("C:\Scripts") Then
Set objFolder = objFSO.CreateFolder("C:\Scripts")
End If

If objFSO.FileExists("C:\Scripts\Test.tsv") Then
Set objFile = objFSO.OpenTextFile("C:\Scripts\Test.tsv",8)
strLine = Aud.Value & vbTab & AFM.Value & vbTab & Hod.Value & vbTab & Van.Value & vbTab & Acc.Value & vbTab & Job.Value & vbTab & Work.Value & vbTab & DWC.Value & vbTab & Tech.Value & vbTab & TechId.Value & vbTab & Cust.Value & vbTab & Post.Value
objFile.WriteLine strLine
objFile.Close
Else
Set objFile = objFSO.CreateTextFile("C:\Scripts\Test.tsv")
strLine = Aud.Value & vbTab & AFM.Value & vbTab & Hod.Value & vbTab & Van.Value & vbTab & Acc.Value & vbTab & Job.Value & vbTab & Work.Value & vbTab & DWC.Value& vbTab & Tech.Value & vbTab & TechId.Value & vbTab & Cust.Value & vbTab & Post.Value
objFile.WriteLine strLine
objFile.Close
End If

This checked for the presence of the folder and created it if necessary.
 
>it still gives same error?

You are absolutely sure it is the same error? As I'd expect you to be getting an Object Required error instead (as hinted at in my previous post).
 
This will recursively create a directory
Code:
function createDirectory (strDir)
	set objFSO = CreateObject("Scripting.FileSystemObject")
	if (right(strDir, 1) = "\") then strDir = left(strDir, len(strDir) - 1)
	strParentDir = objFSO.GetParentFolderName(strDir)
	if NOT (objFSO.FolderExists(strParentDir)) then createDirectory (strParentDir)
	if NOT (objFSO.FolderExists(strDir)) then objFSO.CreateFolder (strDir)
end function

-Geates

 
Also, it might have something to do with your HTML. There are [highlight #CC0000]open elements without closures[/highlight] and [highlight #3465A4]closures without openings.[/highlight] Validate your HTML first to exclude that as a point of error.

Code:
<HTA:APPLICATION
  APPLICATIONNAME="Live Audit HTA"
      SYSMENU="yes"
    border="thin"
    borderstyle="raised"
    maximizebutton="no"
    minimizebutton="no"
    scroll="no"    
    version="1.0"
>

<html>
	<head>
		<script language="vbscript">
			Sub ndhta
				Set objShell = CreateObject("WScript.Shell")
				objShell.Run("2ndhta.hta")
				window.close "close this HTA"
			End Sub
		</script>

		<script language="vbscript">
			Sub SaveData
				Set objFSO = CreateObject("Scripting.FileSystemObject")
				If objFSO.FileExists("C:\Scripts\Test.tsv") Then
					Set objFile = objFSO.OpenTextFile("C:\Scripts\Test.tsv",8)
					strLine = Aud.Value & vbTab & AFM.Value & vbTab & Hod.Value & vbTab & Van.Value & vbTab & Acc.Value & vbTab & Job.Value & vbTab & Work.Value & vbTab & DWC.Value & vbTab & Tech.Value & vbTab & TechId.Value & vbTab & Cust.Value & vbTab & Post.Value
					objFile.WriteLine strLine
					objFile.Close
				Else
					Set objFile = objFSO.CreateTextFile("C:\Scripts\Test.tsv")
					strLine = Aud.Value & vbTab & AFM.Value & vbTab & Hod.Value & vbTab & Van.Value & vbTab & Acc.Value & vbTab & Job.Value & vbTab & Work.Value & vbTab & DWC.Value& vbTab & Tech.Value & vbTab & TechId.Value & vbTab & Cust.Value & vbTab & Post.Value
					objFile.WriteLine strLine
					objFile.Close
				End If
			End Sub
		</script>

		<title>Audit Information</title>

		<link rel="stylesheet" type="text/css" href="style.css">
[highlight #CC0000]		<style type="text/css">[/highlight]
			<style type="text/css">
				body {background-color:#FFFFFF;}
				p {font:bold 18px arial;}
			</style>
	</head>
	<script language="javascript">
		window.moveTo(0,0);
		window.resizeTo(screen.width,screen.height);
	</script>

	<Body>
		<form>
			<div id="footer" style="background-color:#FFA500;clear:both;text-align:center;">Field Technician Live Audit</div><BR><BR><BR><BR><BR>
			<img style= "position:absolute; top: 40px; Left:950px; width:150px; height:90px" src="qual.jpg">
			<table border="5" style="z-index: 1; position: inline; width: 1120px; height: 10px; left: 0px; top: 100px;" width="500" ; align = center>
                <tbody>
					<tr align="center" valign="top">
						<td scope="col"><strong>Auditors Name:&nbsp;<br /></strong></td>
						<td><input id="Aud" maxlength="55" name="Aud" size="35" type="text" /></td>
					</tr>
					<tr align="center" valign="top">
						<td scope="col"><strong>AFM:&nbsp;<br/></strong></td>
						<td><input id="AFM" maxlength="55" name="AFM" size="35" type="text" /></td>
					</tr>
					<tr align="center" valign="top">
						<td scope="col"><strong>HOD Region:&nbsp;<br/></strong></td>
						<td><input id="Hod" maxlength="55" name="Hod" size="35" type="text" /></td>
					</tr>
					<tr align="center" valign="top">
						<td scope="col"><strong>Vehicle Registration:&nbsp;<br/></strong></td>
						<td><input id="VAN" maxlength="55" name="Van" size="35" type="text" /></td>
					</tr>
					<tr align="center" valign="top">
						<td scope="col"><strong>Account Number:&nbsp;<br/></strong></td>
						<td><input id="ACC" maxlength="55" name="ACC" size="35" type="text" /></td>
					</tr>
					<tr align="center" valign="top">
						<td scope="col"><strong>Job Characteristics:&nbsp;<br/></strong></td>
						<td><input id="Job" maxlength="55" name="Job" size="35" type="text" /></td>
					</tr>
					<tr align="center" valign="top">
						<td scope="col"><strong>Work Undertaken:&nbsp;<br/></strong></td>
						<td><input id="Work" maxlength="55" name="Work" size="35" type="text" /></td>
					</tr>
					<tr align="center" valign="top">
						<td scope="col"><strong>Date Work Completed:&nbsp;<br/></strong></td>
						<td><input id="DWC" maxlength="55" name="DWC" size="35" type="text" /></td>
					</tr>
					<tr align="center" valign="top">
						<td scope="col"><strong>Technician Name:&nbsp;<br/></strong></td>
						<td><input id="Tech" maxlength="55" name="Tech" size="35" type="text" /></td>
					</tr>
					<tr align="center" valign="top">
						<td scope="col"><strong>Technician ID:&nbsp;<br/></strong></td>
						<td><input id="TechId" maxlength="55" name="TechId" size="35" type="text" /></td>
					</tr>
					<tr align="center" valign="top">
						<td scope="col"><strong>Customer Address:&nbsp;<br/></strong></td>
						<td><input id="Cust" maxlength="55" name="Cust" size="35" type="text" /></td>
					</tr>
					<tr align="center" valign="top">
						<td scope="col"><strong>Post Code:&nbsp;<br/></strong></td>
						<td><input id="Post" maxlength="55" name="Post" size="35" type="text" /></td>
					</tr>
[highlight #3465A4]					</tr>
					</tr>
[/highlight]				</tbody>
			</table><BR><BR>

			<table width="100%">
				<tbody>
					<tr align="center" valign="top">
						<td><input type="button" value="Save" name="save_button"  onClick="SaveData"><p></p></td>
					</tr>
[highlight #3465A4]					</tr>[/highlight]
				</tbody>
			</table>

[highlight #CC0000]			<div style="position:  absolute;  bottom:  0;">[/highlight]
				<input type="button" value="Continue" name="continue_button"  onClick="ndHta"><p></p></div>
		</form>
		
		<SPAN class=sig><font color="#ff0000">
			Developed By Alfredo Parducci - Virgin Media - 2014.</font>
		</SPAN>
	</body>
</html>

-Geates

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top