Click here to Skip to main content
15,897,226 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Closing a modal dialog box in another Windows app... Pin
Christian Graus10-Feb-07 21:18
protectorChristian Graus10-Feb-07 21:18 
QuestionVB.Net 2005 form reset??? Pin
harveyhanson10-Feb-07 14:03
harveyhanson10-Feb-07 14:03 
AnswerRe: VB.Net 2005 form reset??? Pin
Christian Graus10-Feb-07 14:08
protectorChristian Graus10-Feb-07 14:08 
GeneralRe: VB.Net 2005 form reset??? Pin
harveyhanson10-Feb-07 14:10
harveyhanson10-Feb-07 14:10 
GeneralRe: VB.Net 2005 form reset??? Pin
Christian Graus10-Feb-07 14:28
protectorChristian Graus10-Feb-07 14:28 
QuestionVBA Excel Macros Question - Saving Pictures From the Web Pin
ghettoneck10-Feb-07 12:00
ghettoneck10-Feb-07 12:00 
AnswerRe: VBA Excel Macros Question - Saving Pictures From the Web Pin
Dave Kreskowiak10-Feb-07 13:04
mveDave Kreskowiak10-Feb-07 13:04 
GeneralRe: VBA Excel Macros Question - Saving Pictures From the Web Pin
ghettoneck10-Feb-07 13:33
ghettoneck10-Feb-07 13:33 
That's exactly what I'm trying to do but I still can't get it to work. All I need is this part of the code you provided.

Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const adSaveCreateNotExist = 1
Dim uri
uri = "http://www.csdn.net/Images/logo_csdn.gif"
MyPath = ThisWorkbook.Path
ThisFile = MyPath & Application.PathSeparator

Set xml = CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", uri, False
xml.Send
Set oStream = CreateObject("Adodb.Stream")

oStream.Type = adTypeBinary
oStream.Open
oStream.Write xml.responseBody
oStream.SaveToFile ThisFile, adSaveCreateOverWrite
oStream.Close
Set oStream = Nothing
Set xml = Nothing

When I get to the line

oStream.SaveToFile ThisFIle, adSaveCreateOverWrite

I get an error saying: Run-time error '3004' Write to file failed. Basically I just want the image to be stored in the same folder as my excel file. I may have an error in my file path.

I've tried another example that does work and is very similar to the one you provided but contains a minor problem.

Const adTypeBinary = 1
Const adSaveCreateNotExist = 1
Const TemporaryFolder = 2

Dim oStream ' ADODB.Stream
Dim oFSO ' Scripting.FileSystemObject
Dim xml ' Microsoft.XMLHTTP
Dim sURL
Dim oFil
Dim sImagePath

' create objects
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set xml = CreateObject("Microsoft.XMLHTTP")
Set oStream = CreateObject("Adodb.Stream")

sURL = "http://www.csdn.net/Images/logo_csdn.gif"
' get the temp file...
MyPath = ThisWorkbook.Path
ThisFile = MyPath & Application.PathSeparator & oFSO.GetTempName


xml.Open "GET", sURL, False
xml.Send

oStream.Type = adTypeBinary
oStream.Open
oStream.Write xml.responseBody

' Do not overwrite an existing file
oStream.SaveToFile ThisFile, adSaveCreateNotExist
oStream.Close

' cleanup...
'oFil.Delete
Set oStream = Nothing
Set xml = Nothing
Set oFSO = Nothing
Set oFil = Nothing

The problem with this code is

ThisFile = MyPath & Application.PathSeparator & oFSO.GetTempName

The oFSO.GetTempName creates and stores a .tmp file which is no good to me.

If you could help me figure this out I'd be very grateful
GeneralRe: VBA Excel Macros Question - Saving Pictures From the Web Pin
ghettoneck10-Feb-07 13:42
ghettoneck10-Feb-07 13:42 
QuestionUnpacking in VB.Net Pin
al96810-Feb-07 9:48
al96810-Feb-07 9:48 
Questionform/databse/if statement question. Pin
jady8410-Feb-07 7:17
jady8410-Feb-07 7:17 
AnswerRe: form/databse/if statement question. Pin
Dave Kreskowiak10-Feb-07 8:17
mveDave Kreskowiak10-Feb-07 8:17 
GeneralRe: form/databse/if statement question. Pin
jady8410-Feb-07 11:24
jady8410-Feb-07 11:24 
GeneralRe: form/databse/if statement question. Pin
Christian Graus10-Feb-07 11:37
protectorChristian Graus10-Feb-07 11:37 
AnswerRe: form/databse/if statement question. Pin
Guffa10-Feb-07 11:38
Guffa10-Feb-07 11:38 
GeneralRe: form/databse/if statement question. Pin
jady8410-Feb-07 13:15
jady8410-Feb-07 13:15 
GeneralRe: form/databse/if statement question. Pin
Christian Graus10-Feb-07 14:43
protectorChristian Graus10-Feb-07 14:43 
GeneralRe: form/databse/if statement question. Pin
jady8411-Feb-07 4:22
jady8411-Feb-07 4:22 
GeneralRe: form/databse/if statement question. Pin
Christian Graus11-Feb-07 10:00
protectorChristian Graus11-Feb-07 10:00 
QuestionQuestion - Its urgent Pin
eichmann00910-Feb-07 5:27
eichmann00910-Feb-07 5:27 
AnswerRe: Question - Its urgent Pin
Colin Angus Mackay10-Feb-07 6:01
Colin Angus Mackay10-Feb-07 6:01 
Questionmultyplayers games using a server client communication Pin
yuvalda110-Feb-07 0:18
yuvalda110-Feb-07 0:18 
AnswerRe: multyplayers games using a server client communication Pin
Guffa10-Feb-07 4:17
Guffa10-Feb-07 4:17 
Questionhow could an image be captured from an avi file in vb.net? Pin
Hossein Narimani Rad9-Feb-07 23:36
Hossein Narimani Rad9-Feb-07 23:36 
AnswerRe: how could an image be captured from an avi file in vb.net? Pin
Christian Graus9-Feb-07 23:40
protectorChristian Graus9-Feb-07 23:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.