Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


create textfile with html file

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,57392
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> create textfile with html file
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 create textfile with html file - 3/4/2008 12:58:42 AM   
  diablo

 

Posts: 46
Score: 0
Joined: 3/4/2008
Status: offline
Hello

I'm a starter in VB and I'm creating a webpage (*.hta) where I fill in 2 textboxes and then create a texfile with it. The sub procedure is called when is pushed on a button, but this isn't the issue hé always gives and error on the following code:

<SCRIPT TYPE="text/vbscript">
   Sub verstuur
  
       /* Tekstvelden opslaan in TXT bestand */
      
       Dim fso, bestand, folder, locatie, tempname
       Set fso = CreateObject("Scripting.FileSystemObject")
       locatie = "C:\DummyDTI"
      
       If fso.FolderExists(locatie) Then
           Set folder = fso.GetFolder(locatie)
       Else
           Set folder = fso.CreateFolder(locatie)
       End If

       tempname = filesys.GetTempName

       Set bestand = fso.CreateTextFile(tempname)
       bestand.Write(artikelTitel.value & vbcrlf & vbcrlf & artikel.value)
      
       bestand.Close
       Set fso = nothing
</SCRIPT>
 
 
Post #: 1
 
 RE: create textfile with html file - 3/4/2008 1:01:56 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
What is the error that you get.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to diablo)
 
 
Post #: 2
 
 RE: create textfile with html file - 3/4/2008 1:08:39 AM   
  diablo

 

Posts: 46
Score: 0
Joined: 3/4/2008
Status: offline
Line 22 expected statement

and that's where this part of the code begins

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: create textfile with html file - 3/4/2008 1:24:23 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
Well for one thing I don't see an End Sub statement. I suspect that you also have a sub right before this one that is missing an End Sub statement. Could we see all of your code. Seeing it in context helps understand what is going on.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to diablo)
 
 
Post #: 4
 
 RE: create textfile with html file - 3/4/2008 1:30:36 AM   
  diablo

 

Posts: 46
Score: 0
Joined: 3/4/2008
Status: offline
<html>
<head>
<TITLE>Artikel transferen</TITLE>
<HTA:APPLICATION
       ID="oHTA"
       VERSION="1.0"
       APPLICATIONAME="HTA verstuur artikel"
       CAPTION="yes"
       MAXIMIZEBUTTON="yes"
       MINIMIZEBUTTON="yes"
       BORDER="thick"
       BORDERSTYLE="normal"
       INNERBORDER="yes"
       SCROLL="yes"
       SCROLLFLAT="yes"
       WINDOWSTATE="normal" />

</head>

<SCRIPT TYPE="text/vbscript">
   Sub verstuur
   
       /* Tekstvelden opslaan in TXT bestand */
      
       Dim fso, bestand, folder, locatie, tempname
       Set fso = CreateObject("Scripting.FileSystemObject")
       locatie = "C:\DummyDTI"
      
       If fso.FolderExists(locatie) Then
           Set folder = fso.GetFolder(locatie)
       Else
           Set folder = fso.CreateFolder(locatie)
       End If

       tempname = filesys.GetTempName

       Set bestand = fso.CreateTextFile(tempname)
       bestand.Write(artikelTitel.value & vbcrlf & vbcrlf & artikel.value)
      
       bestand.Close
       Set fso = nothing
      
      
      
       /* DOS commando's in VBscript */
      
       Set WshShell = CreateObject("WScript.Shell")
       WshShell.run "cmd /K"
       /* console venster nog minimaliseren!!!  */
       //MsgBox("Opgelet, selecteer een verbinding!","Verbinding selecteren")
       WshShell.run "RASPHONE"
      
       Set WshShell = Nothing
      
       /* FTP upload */
      
       Set WshShell = CreateObject("WScript.Shell")
       WshShell.run "FTP -i -v -s:ftpscript ftp.rug.be"

       Set WshShell = Nothing

       MsgBox "Bestand verzonden!"
      
      
      
   End Sub


  
  
  
  
</SCRIPT>

<body>
<h2>Artikel ingeven:</h2>

<table border="0" ID="tabel1">
<tr>
<td>Titel:</td>
<td><input type="text" name="artikelTitel" maxlength="30" ID="Text1"></td>
</tr>
<tr>
<td>Artikel:</td>
<td><textarea name="artikel" rows="10" cols="30" id="Text2"></textarea></td>
</tr>
</table>

<br>
<BUTTON onclick="verstuur" ID="verzenden">Verstuur artikel</BUTTON>

</body>

</html>

the FTP part is working  if you place the first part of the code in comment
By the way I can't see an other sub procedure

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: create textfile with html file - 3/4/2008 1:38:26 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
I don't see another sub either, but without seeing all of the code I could not know that. Turns out that the problem is really simple and I should have seen it. The VBScript comment is ' not /*. replace all of the /* comments with '.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to diablo)
 
 
Post #: 6
 
 RE: create textfile with html file - 3/4/2008 1:47:19 AM   
  diablo

 

Posts: 46
Score: 0
Joined: 3/4/2008
Status: offline
quote:

ORIGINAL: ebgreen

I don't see another sub either, but without seeing all of the code I could not know that. Turns out that the problem is really simple and I should have seen it. The VBScript comment is ' not /*. replace all of the /* comments with '.


Are you sure? Because now all the comment is became black where the text was green before and now I got an error on line 25: ActiveX component can't create object: 'scripting.filesystemobject'
Can it be something with my windows XP? I thought that yesterday the first part of the code worked on an other PC butt I'm not sure

(in reply to ebgreen)
 
 
Post #: 7
 
 RE: create textfile with html file - 3/4/2008 1:51:57 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
Well I know for a fact that the VBScript comment is ' If your editor doesn't color code properly you may want to look for a new one. The error you are getting is an IE security policy error.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to diablo)
 
 
Post #: 8
 
 RE: create textfile with html file - 3/4/2008 2:25:16 AM   
  diablo

 

Posts: 46
Score: 0
Joined: 3/4/2008
Status: offline
oh my god It has to do with IE 7 with IE 6 it worked, do you maybe now what setting I have to lower or enable to solve this problem

You are very thanked

(in reply to ebgreen)
 
 
Post #: 9
 
 RE: create textfile with html file - 3/4/2008 2:31:09 AM   
  diablo

 

Posts: 46
Score: 0
Joined: 3/4/2008
Status: offline
on another laptop this time with IE6, I get an error on line 35 object requires filesys :(

(in reply to diablo)
 
 
Post #: 10
 
 RE: create textfile with html file - 3/4/2008 2:34:50 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
You never create the filesys object.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to diablo)
 
 
Post #: 11
 
 RE: create textfile with html file - 3/4/2008 2:47:37 AM   
  diablo

 

Posts: 46
Score: 0
Joined: 3/4/2008
Status: offline
Ah ok stupid of me :) Now the script isn't giving any error anymore but he doesn't make a file in de c:\dummydti map :( and so he can't sent it to the ftp

(in reply to ebgreen)
 
 
Post #: 12
 
 RE: create textfile with html file - 3/4/2008 2:53:18 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
Please post the code that you are running right now so I can know what's going on.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to diablo)
 
 
Post #: 13
 
 RE: create textfile with html file - 3/4/2008 2:56:52 AM   
  diablo

 

Posts: 46
Score: 0
Joined: 3/4/2008
Status: offline
I didn't change much butt here is the code again

<html>
<head>
<TITLE>Artikel transferen</TITLE>
<HTA:APPLICATION
       ID="oHTA"
       VERSION="1.0"
       APPLICATIONAME="HTA verstuur artikel"
       CAPTION="yes"
       MAXIMIZEBUTTON="yes"
       MINIMIZEBUTTON="yes"
       BORDER="thick"
       BORDERSTYLE="normal"
       INNERBORDER="yes"
       SCROLL="yes"
       SCROLLFLAT="yes"
       WINDOWSTATE="normal" />

</head>

<SCRIPT TYPE="text/vbscript">
   Sub verstuur
  
       'Tekstvelden opslaan in TXT bestand
      
       Dim fso, bestand, folder, locatie, tempname, filesys
       Set fso = CreateObject("Scripting.FileSystemObject")
       locatie = "C:\DummyDTI"
      
       If fso.FolderExists(locatie) Then
           Set folder = fso.GetFolder(locatie)
       Else
           Set folder = fso.CreateFolder(locatie)
       End If

       Set filesys = CreateObject("Scripting.FileSystemObject")
       tempname = filesys.GetTempName

       Set bestand = fso.CreateTextFile(tempname)
       bestand.Write(artikelTitel.value & vbcrlf & vbcrlf & artikel.value)
      
       bestand.Close
       Set fso = nothing
      
      
      
       'DOS commando's in VBscript
      
       Set WshShell = CreateObject("WScript.Shell")
       WshShell.run "cmd /K"
       'console venster nog minimaliseren!!!
       'MsgBox("Opgelet, selecteer een verbinding!","Verbinding selecteren")
       WshShell.run "RASPHONE"
      
       Set WshShell = Nothing
      
       'FTP upload
      
       Set WshShell = CreateObject("WScript.Shell")
       WshShell.run "FTP -i -v -s:ftpscript ftp.rug.be"

       Set WshShell = Nothing

       MsgBox "Bestand verzonden!"
      
      
      
   End Sub


  
  
  
  
</SCRIPT>

<body>
<h2>Artikel ingeven:</h2>

<table border="0" ID="tabel1">
<tr>
<td>Titel:</td>
<td><input type="text" name="artikelTitel" maxlength="30" ID="Text1"></td>
</tr>
<tr>
<td>Artikel:</td>
<td><textarea name="artikel" rows="10" cols="30" id="Text2"></textarea></td>
</tr>
</table>

<br>
<BUTTON onclick="verstuur" ID="verzenden">Verstuur artikel</BUTTON>

</body>

</html>

(in reply to ebgreen)
 
 
Post #: 14
 
 RE: create textfile with html file - 3/4/2008 3:06:12 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
You don't give any path information when you create the file so I suspect it is making the file in whatever your working directory is.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to diablo)
 
 
Post #: 15
 
 RE: create textfile with html file - 3/4/2008 4:00:03 AM   
  diablo

 

Posts: 46
Score: 0
Joined: 3/4/2008
Status: offline
quote:

ORIGINAL: ebgreen

You don't give any path information when you create the file so I suspect it is making the file in whatever your working directory is.


I'm making the file in locatie = "C:\DummyDTI"?

(in reply to ebgreen)
 
 
Post #: 16
 
 RE: create textfile with html file - 3/4/2008 4:04:59 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
Nowhere in this code:

      tempname = filesys.GetTempName

      Set bestand = fso.CreateTextFile(tempname)


Which creates the file do you ever tell it anything about locatie = "C:\DummyDTI"?

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to diablo)
 
 
Post #: 17
 
 RE: create textfile with html file - 3/4/2008 6:02:34 AM   
  diablo

 

Posts: 46
Score: 0
Joined: 3/4/2008
Status: offline
quote:

ORIGINAL: ebgreen

Nowhere in this code:

     tempname = filesys.GetTempName

    Set bestand = fso.CreateTextFile(tempname)


Which creates the file do you ever tell it anything about locatie = "C:\DummyDTI"?


oeps then it should be: Set bestand = fso.CreateTextFile("C:\DummyDTI\tempname", True)

The function GetTempName will this give me a TXT file, because on a website I saw it would give a *.tmp file? butt I need a TXT file
And secondly is it easy to automatically count the amount of characters there are typed in the textarea?

Do you have good website where I can learn more about VBscript? You maybe have also a better vbscript editor then Visual Studio?

I very much thank you for you're help

(in reply to ebgreen)
 
 
Post #: 18
 
 RE: create textfile with html file - 3/4/2008 6:06:09 AM   
  ebgreen


Posts: 4972
Score: 31
Joined: 7/12/2005
Status: offline
There is a thread pinned at the top of this forum that discusses various editors

Set bestand = fso.CreateTextFile("C:\DummyDTI\" & Replace(tempname, ".tmp", ".txt"), True)

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to diablo)
 
 
Post #: 19
 
 RE: create textfile with html file - 3/4/2008 6:50:31 PM   
  diablo

 

Posts: 46
Score: 0
Joined: 3/4/2008
Status: offline
I get the following error on line 88: type mismatch?

and when I leave my filed artikel I get an error on line 108: object doesn't support this property or method

<html>
<head>
<TITLE>CONCENTRA</TITLE>
<HTA:APPLICATION
       ID="oHTA"
       VERSION="1.0"
       APPLICATIONAME="HTA verstuur artikel"
       CAPTION="yes"
       MAXIMIZEBUTTON="yes"
       MINIMIZEBUTTON="yes"
       BORDER="thick"
       BORDERSTYLE="normal"
       INNERBORDER="yes"
       SCROLL="yes"
       SCROLLFLAT="yes"
       WINDOWSTATE="normal" />

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
<!--
body {
   background-color: #FFFFFF;
}
.style3 {font-size: 12px}
-->
</style>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>

<SCRIPT TYPE="text/vbscript">
   Sub verstuur
   
       'Tekstvelden opslaan in TXT bestand
      
       Dim fso, bestand, folder, locatie, tempname, filesys
       Set fso = CreateObject("Scripting.FileSystemObject")
       locatie = "C:\DummyDTI"
      
       If fso.FolderExists(locatie) Then
           Set folder = fso.GetFolder(locatie)
       Else
           Set folder = fso.CreateFolder(locatie)
       End If

       Set filesys = CreateObject("Scripting.FileSystemObject")
       tempname = filesys.GetTempName

       Set bestand = fso.CreateTextFile("C:\DummyDTI\" & Replace(tempname, ".tmp", ".txt"), True)
       bestand.Write(artikelTitel.value & vbcrlf & vbcrlf & artikel.value)
      
       bestand.Close
       Set fso = nothing
      
      
      
       'DOS commando's in VBscript
      
       Set WshShell = CreateObject("WScript.Shell")
       WshShell.run "cmd /K"
       'console venster nog minimaliseren!!!
       'MsgBox("Opgelet, selecteer een verbinding!","Verbinding selecteren")
       WshShell.run "RASPHONE"
      
       Set WshShell = Nothing
      
       'FTP upload
      
       Set WshShell = CreateObject("WScript.Shell")
       WshShell.run "FTP -i -v -s:ftpscript ftp.rug.be"

       Set WshShell = Nothing

       MsgBox "Bestand verzonden!"
      
      
      
   End Sub

   Sub Window_Onload
       strComputer = "."
       Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
       Set colItems = objWMIService.ExecQuery("Select * From Win32_DesktopMonitor")
       For Each objItem in colItems
           intHorizontal = objItem.ScreenWidth
           intVertical = objItem.ScreenHeight
       Next
       intLeft = (intHorizontal - 800) / 2
       intTop = (intVertical - 600) / 2
       window.resizeTo 650,450
       window.moveTo intLeft, intTop
   End Sub
  
  
  
  
</SCRIPT>

<body>
<table border="0" ID="tabel1">
<tr>
<td>&nbsp;</td>
<td colspan="2"><div align="center"><img src="logo-verticaal.gif" alt="Het Belang van Limburg" width="246" height="80"></div></td>
</tr>
<tr>
<td width="59">Titel:</td>
<td colspan="2"><input name="artikelTitel" type="text" ID="Text1" size="50" maxlength="30"></td>
</tr>
<tr>
<td align="left" valign="top">Artikel:</td>
<td colspan="2"><textarea name="artikel" cols="50" rows="10" id="Text2" onchange="vermeerder"></textarea></td>
</tr>
<tr>
<td align="left" valign="top">Aantal karakters:</td>
<td colspan="2">
<label>
<script type="text/vbscript">
Sub vermeerder
   dim tel
   tel=cstr(artikel.count)
   document.write(tel)
End Sub
</script>

</label></td>
</tr>
<tr>
<td align="left" valign="top">&nbsp;</td>
<td width="86">&nbsp;</td>
<td width="247"><input type="submit" name="submit" id="verzenden1" value="Verzend artikel" onClick="verstuur"></td>
</tr>
<tr>
<td colspan="3" align="left" valign="top">&nbsp;</td>
</tr>
<tr>
<td colspan="3" align="left" valign="top"><span class="style3">Steven</span></td>
</tr>
</table>

<br>
</body>

</html>

(in reply to ebgreen)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> create textfile with html file Page: [1] 2   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts