Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Inet control to save online image to disk 2

Status
Not open for further replies.

kar202

Programmer
Jun 28, 2002
16
US
I know that the Inet control gives me this ability, but so far I am not having any success. What I want is nothing fancy, just this:

A button is clicked, and the .jpeg at is saved to C:\Windows\temp

That's all I want, yet I can't seem to perform this without lines upon lines of code. Any ideas? I would greatly appreciate any help. And, yes, I have already been to and it did not help. When I insert that code into my VB, half of it is unrecognized, plus it's trying to do way more than I need.
 
Looks like you didn't add the reference to the Microsoft HTML Object library

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Well, no, I have added all the references. For example, "New FileSystemObject" gives me "user defined type not defined.
 
The FileSystemObject needs a reference to Microsoft Scripting Runtime, which is in scrrun.dll

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Given that you already have the URL direct to the jpeg image, you only really need to focus on about 1 line from my example in that thread:

bytearray() = Inet1.OpenURL(HTMLImage.Attributes("src").Value, icByteArray)

which would read

bytearray() = Inet1.OpenURL(<your_jpeg_url>, icByteArray)



 
Thanks so much for your help. Unfortunately, it still isn't working in the way I need it. I added the scrrun.dll at the suggestion of johnwm and the FileSystemObject began working. I ran the original program that strongm created and it worked fine. However, I found that if I wanted to do another web site, I had to close and then re-open visual basic because the program seemed to be attached to that C:\testhtml folder for some reason.

Anyway, then I added my URL to SavePageToFolder in the command button. (strongm, did you forget to mention that I had to change that, too?) The program downloaded a 62 byte file called "armageddon.jpg" but when previewed displayed nothing. And the real .jpg is actually 20kb. In other words, that wasn't the picture, rather a... I don't know what to call it... file that represents the fact that a real .jpg called "armageddon.jpg" exists there. The url I gave, leading directly to the picture isn't actually a web page, it's THE picture, so I don't think I can download using it the program as it is. Any suggestions? Thanks so much for your help so far.

kar202
 
If you want to display that image in your program eventually, see thread222-708828 for directly displaying an image from the web, without requiring to save it to disk.

After pulling the image from the web, you can also save it to disk using the SavePicture method, although that would save the image in bitmap format, instead of JPEG.
 
Hypetia, I've checked into that a little, but I actually am putting the images into Microsoft Word using VBA, and in order to use the .selection.addpicture (or something like that) method, I have to have the .jpg saved to the disk. If you know of a way in which I could transport the .jpg directly to Microsoft Word I would be very appreciative, but I don't know of such a way. Thanks.
 
Hypetia, I've checked into that a little, but I actually am putting the images into Microsoft Word using VBA, and in order to use the .selection.addpicture (or something like that) method, I have to have the .jpg saved to the disk. If you know of a way in which I could transport the .jpg directly to Microsoft Word I would be very appreciative, but I don't know of such a way. Thanks.

At the moment, I do have the program working, just not as efficiently as I'd like. Using strongm's code, I am d/ling all images of a higher directory, then grabbing the exact file I need. I'd like to just grab the exact file rather than have extra files filling up C:\Windows\temp (the folder I am storing the files in).
 
Sorry for the double post.

OK, now when I build the program and try to run it on a computer that doesn't have VB6.0 installed, I get "cannot find MSINET.ocx" or something like that. Is there anyway I can correct this so any computer can run the program? Thanks.
 
Looks like you're copying the .EXE rather than using an installer. Do a search on the Forum for Installer or PDW

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top