Results 1 to 9 of 9

VBA Mac - Downloading image not working (But working in Windows)

Threaded View

  1. #1
    Registered User
    Join Date
    05-22-2011
    Location
    chennai
    MS-Off Ver
    Excel 2003
    Posts
    71

    VBA Mac - Downloading image not working (But working in Windows)

    Hi

    I have created a macro file to download images from website to folder - its working fine in Windows but its not working in Excel for Mac 2011, OSX 10.9.5 (Mavericks).

    Also attached file.

    This is the code that i have used - Is there any other way to download from url using vba excel.

    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
    
    Dim Ret As Long
    
    '~~> This is where the images will be saved. Change as applicable
    Const FolderName As String = "C:\Users\MattGold\Desktop\Images\"
    
    Sub Sample()
        Dim ws As Worksheet
        Dim LastRow As Long, i As Long
        Dim strPath As String
        
    
        '~~> Name of the sheet which has the list
        Set ws = Sheets("LOAD")
    
        LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
    
        For i = 2 To LastRow '<~~ 2 because row 1 has headers
            strPath = FolderName & ws.Range("A" & i).Value & ".jpg"
    
            Ret = URLDownloadToFile(0, ws.Range("B" & i).Value, strPath, 0, 0)
    
            If Ret = 0 Then
                ws.Range("C" & i).Value = "File successfully downloaded"
            Else
                ws.Range("C" & i).Value = "Unable to download the file"
            End If
        Next i
    End Sub
    Please help me on this.

    Thanks
    Thiru
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA Mac - Downloading image not working (But working in Windows)
    By sthiru in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-18-2014, 08:45 AM
  2. VBA code Error after changed to windows 7, working fine in windows XP before
    By Faridwahidi in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-11-2014, 06:23 AM
  3. Macros created in Windows XP not opening /working in Windows 7
    By Janane in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-18-2012, 04:28 AM
  4. Power pivot is not downloading, or working
    By AB33 in forum Excel General
    Replies: 0
    Last Post: 08-06-2012, 12:47 PM
  5. ocde working in one windows login but stopped working in another.
    By rama1209 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-02-2011, 08:38 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1