Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Writing to IE or a file won't work

Reply
 
Old 06-14-2009   #1 (permalink)
Mike H


 
 

Writing to IE or a file won't work

This is two problems in one: a problem and a solution that doesn't work.
I need to convert files of plain text and send it to Internet Explorer as
HTML.
So I created an IE object like this:
Set oIE = WScript.CreateObject("InternetExplorer.Application")
oIE.Navigate "About:blank"
Set oIEDoc = oIE.Document
and write to it like this:
oIEDoc.Writeln "<HTML>" . . . . . . . . . . . .

And that creates and displays the correct HTM but it won't display the
pictures.
The picture paths are all correct.
If I ViewSource (in IE), save the page, then change the Navigate line to:
oIE.Navigate "F:\P.htm"
Then rerun it, it will display the photos correctly.
And that tells me it's not an HTML problem.

So question 1:
Does anyone know why IE (vista) won't display the photos when using the
About:blank document?

Then to correct that problem I tried writing the same HTM to a file first,
like this:
Set oFSO = CreateObject ("Scripting.FileSystemObject")
Set oOutput = oFS0.CreateTextFile ("F:\P.htm", true)
oOutput.Writeln "<HTML>" . . . . . . . . . . . .

But this refuses to create the file,
whether the file exists or not nothing happens, no error and no file.
The F: drive has full permissions for everyone,
and it let me create the file manually in Notepad.

So question 2:
Does anyone know why the CreateTextFile method might not work?


My System SpecsSystem Spec
Old 06-14-2009   #2 (permalink)
mayayana


 
 

Re: Writing to IE or a file won't work

I don't know about why you might not be able
to create a file when you have permission,
but you don't seem to be posting the actual code here.

Posting a recreation/facsimile just wastes everyone's
time.

As written, your posted code first fails because you
used oFSO as the object, then called CreateTextFile
with oFS0. (Last char. is zero instead of the letter O.)
Then in the third line you used a method that doesn't
exist for TextStream. WriteIn is an IE method.

So how is it that you have 2 fatal errors in
3 lines and you didn't find that out when you
ran the script?!
Quote:

> Set oFSO = CreateObject ("Scripting.FileSystemObject")
> Set oOutput = oFS0.CreateTextFile ("F:\P.htm", true)
> oOutput.Writeln "<HTML>" . . . . . . . . . . . .
>
> But this refuses to create the file,
> whether the file exists or not nothing happens, no error and no file.
> The F: drive has full permissions for everyone,


My System SpecsSystem Spec
Old 06-15-2009   #3 (permalink)
Mike H


 
 

Re: Writing to IE or a file won't work

Thanks for the info, I can't believe I never noticed the zero.
When I tried it, it worked.

But:
Quote:

> you don't seem to be posting the actual code here.
This is the actual code.
Quote:

> Posting a recreation/facsimile . . .
It's not a facsimile, it's the exact code.
Quote:

> Posting a recreation/facsimile just wastes everyone's time.
That's obviously not true since you found the problem.
Quote:

> WriteIn is an IE method.
I never would have guessed that IE and TextStream objects would use two
different write methods.
Quote:

> 2 fatal errors in and you didn't find that out when you ran the script?
The VBS interpreter never choked on either error.


My System SpecsSystem Spec
Old 06-15-2009   #4 (permalink)
mayayana


 
 

Re: Writing to IE or a file won't work

Quote:
Quote:

> > WriteIn is an IE method.
> I never would have guessed that IE and TextStream objects would use two
> different write methods.
>
Textstream is part of the scripting runtime, a whole
different kettle of fish. The IE DOM (Document Object
Model) has some similarities with other standards that
Microsoft uses. (For instance, the notion of a "TextRange"
is used in the DOM and also in the RichEdit API,) But in
general the IE DOM is unique.

The scripting runtime (scrrun.dll) was designed
especially for the Windows Script Host. At the time
the Microsoft designers thought (mistakenly) that only
plain text file access would be relevant with WSH. I guess
that partially explains why they came up with a gimmicky
name like "Textstream" and didn't use something less
confusing like...maybe..."File".

Quote:
Quote:

> > 2 fatal errors in and you didn't find that out when you ran the script?
> The VBS interpreter never choked on either error.
>
Maybe you had error trapping in place? If
you use On Error Resume Next and don't comment
it out for debugging then you wouldn't get an error.
When I tried only those 3 lines the first error was
"Object required" because I was trying to call
CreateTextFile with the oFS[zero] object, which of
course wasn't an object.


My System SpecsSystem Spec
Old 06-16-2009   #5 (permalink)
Mike H


 
 

Re: Writing to IE or a file won't work

Thanks, that's all good to know.
I am using On Error Resume Next.
The two corrections worked so it looks like I'm good to go.


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Writing File to CD ROM VB Script
Writing A CD/DVD doesn't work .NET General
Hand writing doesn't work Live Messenger
writing out to file PowerShell
Writing generic cmdlets that work across different (navigation) providers PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46