MrExcel Message Board


Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Dec 15th, 2004, 08:16 PM   #1
yee388
 
yee388's Avatar
 
Join Date: Mar 2004
Location: Spring, TX
Posts: 1,374
Default .Picture property question

Can I use a web location for the .Picture source on my Image control?

This is giving me some errors...

Code:
Image1.Picture = LoadPicture("http://www.mywebsitehere.com/MyFolder/Test.jpg")
NOTE: This is just example text.. don't try to go to the link...
yee388 is offline   Reply With Quote
Old Dec 15th, 2004, 08:43 PM   #2
Haluk
 
Haluk's Avatar
 
Join Date: Oct 2002
Location: Turkiye
Posts: 832
Default

Try using a WebBrowser control and use the code below;

Code:
WebBrowser1.Navigate "about:"
Haluk is offline   Reply With Quote
Old Dec 15th, 2004, 08:53 PM   #3
yee388
 
yee388's Avatar
 
Join Date: Mar 2004
Location: Spring, TX
Posts: 1,374
Default

Excellent. Going to read up on more details on this "new" control. Help menu doesn't seem to be much help on this topic...
yee388 is offline   Reply With Quote
Old Dec 15th, 2004, 09:02 PM   #4
Haluk
 
Haluk's Avatar
 
Join Date: Oct 2002
Location: Turkiye
Posts: 832
Default

Quote:
Help menu doesn't seem to be much help on this topic...
That's true because it is not an OfficeVBA control........ actually, it is a VB control.
Haluk is offline   Reply With Quote
Old Dec 15th, 2004, 10:03 PM   #5
Juan Pablo González
MrExcel MVP
 
Join Date: Feb 2002
Location: Bogota, Colombia
Posts: 11,771
Default Re: .Picture property question

What follows is a modification from

http://vbnet.mvps.org/index.html?cod...ilenocache.htm

Put the following in a standard module:

Option Explicit

Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
****"URLDownloadToFileA" (ByVal pCaller As Long, _
****ByVal szURL As String, ByVal szFileName As String, _
****ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
**
Private Declare Function DeleteUrlCacheEntry Lib "Wininet.dll" _
****Alias "DeleteUrlCacheEntryA" ( _
****ByVal lpszUrlName As String) As Long

Private Declare Function GetTempFileName Lib "kernel32" Alias _
****"GetTempFileNameA" (ByVal lpszPath As String, _
****ByVal lpPrefixString As String, ByVal wUnique As Long, _
****ByVal lpTempFileName As String) As Long

Private Declare Function SetFileAttributes Lib "kernel32" Alias _
****"SetFileAttributesA" (ByVal lpFileName As String, _
****ByVal dwFileAttributes As Long) As Long

**
Private Const ERROR_SUCCESS As Long = 0
Private Const BINDF_GETNEWESTVERSION As Long = &H10
Private Const INTERNET_FLAG_RELOAD As Long = &H80000000
Private Const FILE_ATTRIBUTE_TEMPORARY = &H100


Private Function DownloadFile(sSourceUrl As String, _
******************************sLocalFile As String) As Boolean
**
**'Download the file. BINDF_GETNEWESTVERSION forces
**'the API to download from the specified source.
**'Passing 0& as dwReserved causes the locally-cached
**'copy to be downloaded, if available. If the API
**'returns ERROR_SUCCESS (0), DownloadFile returns True.
** DownloadFile = URLDownloadToFile(0&, _
************************************sSourceUrl, _
************************************sLocalFile, _
************************************BINDF_GETNEWESTVERSION, _
************************************0&) = ERROR_SUCCESS
**
End Function

Function LoadPictureUrl(sSourceUrl As String) As IPictureDisp
** Dim sLocalFile As String
**
** On Error GoTo err_h
**
** 'Create a buffer
** sLocalFile = String(260, 0)
** 'Get a temporary filename
** GetTempFileName "C:\", "KPD", 0, sLocalFile
** 'Remove all the unnecessary chr$(0)'s
** sLocalFile = Left$(sLocalFile, InStr(1, sLocalFile, Chr$(0)) - 1)
** 'Set the file attributes
** SetFileAttributes sLocalFile, FILE_ATTRIBUTE_TEMPORARY

**'Attempt to delete any cached version of the file.
** DeleteUrlCacheEntry sSourceUrl
**
** If DownloadFile(sSourceUrl, sLocalFile) = True Then

******'hfile = FreeFile
******'Open sLocalFile For Input As #hfile
******'Text1.Text = Input$(LOF(hfile), hfile)
******'Close #hfile
******Set LoadPictureUrl = LoadPicture(sLocalFile)
******Kill sLocalFile
** Else
******'Create a bogus error
******Err.Raise 999
** End If

** Exit Function
err_h:
** Set LoadPictureUrl = LoadPicture("")
End Function


now, you can call this function like


Private Sub Command1_Click()
** Dim Url As String
** Url = "http://www.mrexcel.com/board2/images/avatars/1739339495404fef2bc2773.gif"
** Image1.Picture = LoadPictureUrl(Url)
End Sub
__________________
Regards,

Juan Pablo González
http://www.juanpg.com
Juan Pablo González is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT +1. The time now is 04:15 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
All contents Copyright 1998-2010 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes