WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with MSIE
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

ExecCommand Saveas dialog problem

 Keywords: ExecCommand Saveas dialog @False 

Question:

The attached script will do basically what I want in order to get the URL to ASCII, which can then be forwarded to the parser for conversion into [probably] XML.
  1. The SaveAs section of the execCommand(), always prompts to save the file, even with @FALSE passed - is there a way around this.
  2. After extracting the HTML text, I want to close the IE Window and obviously the standard oBJ.Close() fails, and I could not find info on MSDN.
cSave  = "E:\WBDEMO\OETEMP.HTM"
cURL   = "http://www.winbatch.com"
cFile  = "E:\WBDEMO\STRIP.TXT"

If FileExist(cSave)
   FileDelete(cSave)
Endif

AddExtender("wwwsk34i.dll")

oE     = ObjectAccess("InternetExplorer.Application",@TRUE)
oE.Visible = @True
oE.Navigate(cURL)

While oE.readystate<>4
   TimeDelay(1)
EndWhile

oDoc = oE.Document
oDoc.ExecCommand("SaveAs",@FALSE,cSave)
ObjectCLose(oDoc)
ObjectCLose(oE)


fs     = FileSize(cSave)
bb     = BinaryAlloc(fs)
BinaryRead(bb,cSave)
cStrip = BinaryPeekStr(bb,0,fs)
BinaryFree(bb)
cStrip=httpStripHTML(cStrip)

handle = FileOpen(cFile,"WRITE")
FileWrite(handle,cStrip)
FileClose(handle)
exit

Answer:

See the following MDSN article regarding the Use of SaveAs :

A Moving and a Shaking
----------------------
Read the section 'Save the Last GIF for Me '
http://msdn.microsoft.com/en-us/library/bb250487(VS.85).aspx#webteam03052001_topic2

In short, its caused by a security catch 22.

You might take a look into using the Wininet extender functions to handle the webpage retrieval...

Here is an example:

cSave  = "c:\temp\OETEMP.HTM"
cURL   = "http://www.winbatch.com"
cFile  = "c:\temp\STRIP.TXT"

If FileExist(cSave)
  FileDelete(cSave)
Endif

AddExtender("wwwsk34i.dll")
AddExtender("WWINT34i.DLL")
tophandle=iBegin(0,"","")
datahandle=iUrlOpen(tophandle,cURL)
xx=iReadData(datahandle,cSave)
iClose(datahandle)
iClose(tophandle)

fs     = FileSize(cSave)
bb     = BinaryAlloc(fs)
BinaryRead(bb,cSave)
cStrip = BinaryPeekStr(bb,0,fs)
BinaryFree(bb)
cStrip=httpStripHTML(cStrip)
handle = FileOpen(cFile,"WRITE")
FileWrite(handle,cStrip)
FileClose(handle)
exit


Article ID:   W14934
File Created: 2010:09:01:08:57:10
Last Updated: 2010:09:01:08:57:10