![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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. Quote: > Posting a recreation/facsimile . . . Quote: > Posting a recreation/facsimile just wastes everyone's time. Quote: > WriteIn is an IE method. different write methods. Quote: > 2 fatal errors in and you didn't find that out when you ran the script? |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Writing to IE or a file won't work Quote: Quote: > > WriteIn is an IE method. > different write methods. > 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? > 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 Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||