Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


passing filename to VB

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> passing filename to VB
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 passing filename to VB - 8/31/2007 2:50:08 AM   
  cmc

 

Posts: 13
Score: 0
Joined: 5/30/2007
Status: offline
Hi Guys,

Should something like this work to pass the filename into a VB script ? 

Dim sFFSpec : sFFSpec    = oFS.GetAbsolutePathName( "D:\test\UTF8\""& oArgs.Item(0) &")
Dim sTFSpec : sTFSpec    = oFS.GetAbsolutePathName( "D:\test\UTF8\""& oArgs.Item(0) &")

Thanks
 
 
Post #: 1
 
 RE: passing filename to VB - 8/31/2007 3:08:24 AM   
  ebgreen


Posts: 5250
Score: 31
Joined: 7/12/2005
Status: offline
Try it and find out. You could have done it several times over in the time that you posted this question and waited for an answer.

_____________________________

"... 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 cmc)
 
 
Post #: 2
 
 RE: passing filename to VB - 8/31/2007 3:15:31 AM   
  cmc

 

Posts: 13
Score: 0
Joined: 5/30/2007
Status: offline
Ops I meant it doesn't work, well it compiles but later in the program when it tries to open the file it can't

D:\test\UTF8\preview_utf8_2.vbs(20, 2) ADODB.Stream: File could not be opened.

Const adTypeBinary = 1
Const adTypeText   = 2
Const bOverwrite   = True
Const bAsASCII     = False
Dim oFS     : Set oFS    = CreateObject( "Scripting.FileSystemObject" )
Dim sFFSpec : sFFSpec    = oFS.GetAbsolutePathName( "D:\test\UTF8\""& oArgs.Item(0) &")
Dim sTFSpec : sTFSpec    = oFS.GetAbsolutePathName( "D:\test\UTF8\""& oArgs.Item(0) &")

Dim oFrom   : Set oFrom  = CreateObject( "ADODB.Stream" )
Dim sFrom   : sFrom      = "Windows-1252"
Dim oTo     : Set oTo    = CreateObject( "ADODB.Stream" )
Dim sTo     : sTo        = "utf-8"
oFrom.Type    = adTypeText
oFrom.Charset = sFrom
oFrom.Open
oFrom.LoadFromFile sFFSpec
WScript.Echo oFrom.Size & " Bytes in " & sFFSpec
If oFS.FileExists( sTFSpec ) Then oFS.DeleteFile sTFSpec
oTo.Type    = adTypeText
oTo.Charset = sTo
oTo.Open
oTo.WriteText oFrom.ReadText
WScript.Echo oTo.Size & " Bytes in " & sTFSpec
oTo.SaveToFile sTFSpec
oFrom.Close
oTo.Close

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: passing filename to VB - 8/31/2007 3:19:14 AM   
  ebgreen


Posts: 5250
Score: 31
Joined: 7/12/2005
Status: offline
And you are sure that the file is there and that it is not locked by some other process?

_____________________________

"... 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 cmc)
 
 
Post #: 4
 
 RE: passing filename to VB - 8/31/2007 3:25:22 AM   
  cmc

 

Posts: 13
Score: 0
Joined: 5/30/2007
Status: offline
its defo there, I've put in a  WScript.Echo " File in " & sTFSpec
to see what its reading and it at Dim sFFSpec : sFFSpec    = oFS.GetAbsolutePathName( "D:\test\UTF8\"& "oArgs.Item(0)")
and it returns
File in D:\test\UTF8\oArgs.Item(0)

should be the filename
cscript D:\test\UTF8\preview_utf8_2.vbs 1000720.htm

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: passing filename to VB - 8/31/2007 3:32:55 AM   
  cmc

 

Posts: 13
Score: 0
Joined: 5/30/2007
Status: offline
Thanks anyway,

but got it I was missing the Set oArgs = WScript.Arguments.Unnamed

(in reply to cmc)
 
 
Post #: 6
 
 
 
  

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 >> passing filename to VB Page: [1]
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