Rabu, 27 Juli 2011

[MS_AccessPros] Re: help with vbs script code

 

Sarah

Let me see what I can do with this. Is there any more code in the VBScipt file?

Bill Mosca

--- In MS_Access_Professionals@yahoogroups.com, "novice012000" <sarahk@...> wrote:
>
> The following is not related directly to MSAccess, but since there are great experts in this group, I am allowing myself to post the question here. I have exhausted other possibilities.
> I have the following code that I run from a command prompt with wscript. It reads the contents of a file that I pass to the script. The file content has the name of an image file (.jpg) that I want to automatically open. Everything works fine, I display the file name first and it is correct, but the wshell.open does not do anything, or maybe it does open the file but closes it immediately, because I also tried the command with the hard coded file name (now commented out) and I think I see it flashing in the background, but it is immediately closed. The script does not return any error messages.
>
> Here it is:
> Option Explicit
> Dim objargs, INputfile, objFso,objFile, objReadfile, strContents, LoadPicture, stypic, wshell, shell
> set objargs=wscript.arguments
> INputfile = objargs(0)
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> Set objFile = objFSO.GetFile(inputfile)
> Set objReadFile = objFSO.OpenTextFile(inputfile, 1)
> strContents = objReadFile.ReadAll
> Wscript.Echo strContents
> 'objReadFile.Close
> set wShell = CreateObject("Shell.Application")
> wShell.Open strContents
>
> 'wShell.open "F:\SCHEME\SUBCMT\STYLES\pictures\Scenic001.jpg"
>
> ' Set wshell = Nothing
>
> I checked that strContents contains "F:\SCHEME\SUBCMT\STYLES\pictures\Scenic001.jpg" and the file exsits, but 'nothing' happens when wshell.open is executed.
>
> All help is as always greatly appreciated.
> Sarah
>

__._,_.___
Recent Activity:
.

__,_._,___

Tidak ada komentar:

Posting Komentar