Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Can VBscript open files

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

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Can VBscript open files
  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 >>
 Can VBscript open files - 1/7/2002 4:06:48 PM   
  James2

 

Posts: 3
Score: 0
Joined: 1/7/2002
From:
Status: offline
Hi All,

Assuming I know the directory of the file I want to access (i.e a word document), can I use VBscript to open the file? If so what is the code to perform this task.

Thank you in advance.

James
 
 
Post #: 1
 
 Re: Can VBscript open files - 1/9/2002 5:36:55 PM   
  Tory

 

Posts: 16
Score: 0
Joined: 11/13/2001
From: USA
Status: offline
OPTION EXPLICIT
dim fso, ws, file_to_open, OFFICE_PATH

Set ws = WScript.CreateObject("WScript.Shell")

'Your path to Winword.exe may be different or even better it may already be
'in your %PATH% Environment variable and youy can dump this variable
OFFICE_PATH = "C:\Program Files\Microsoft Office\Office"

'You need to quote paths with spaces by using Chr(34) which is HEX for double quote.
file_to_open = CHR(34) & "C:\my documents\archive\my dog.doc" & CHR(34)

ws.Run CHR(34)& OFFICE_PATH & "\winword.exe" & CHR(34) & file_to_open, 0, "FALSE"

(in reply to James2)
 
 
Post #: 2
 
 
 
  

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 >> Can VBscript open files 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