+ Reply to Thread
Results 1 to 2 of 2

Compatibility issue between Excel 2007 to Excel 2003

Hybrid View

  1. #1
    Registered User
    Join Date
    09-18-2009
    Location
    Chennai
    MS-Off Ver
    Excel 2007
    Posts
    25

    Compatibility issue between Excel 2007 to Excel 2003

    The following code is not working in excel 2003 where as It's working fine in excel 2007.
    I guess there is a compatibility issue. how to change this to work fine in excel 2003 version.

    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
    
    
    Sub DownloadFileFromWeb()
    Dim i As Integer
    
        Const strUrl As String = "https://myportal.com/ZZDR6.csv"
    
        Dim strSavePath As String
        Dim returnValue As Long
        
        strSavePath = "\\filesrv01\dsdf\SE\EERDV_1.csv"
    
        returnValue = URLDownloadToFile(0, strUrl, strSavePath, 0, 0)
        
    End Sub

  2. #2
    Valued Forum Contributor MaczaQ's Avatar
    Join Date
    06-03-2011
    Location
    Poland
    MS-Off Ver
    Excel 2003 / XP
    Posts
    510

    Re: Compatibility issue between Excel 2007 to Excel 2003

    Hi simi,

    I tried Your code but it didn't work for both (2003 and 2k7)
    Probable problem is because you tried to get a file from HTTPS (shouldn't you send login and password for that protocol ?)

    I also tried my similar code and doesn't work for source address in 2003 and in 2007
    Option Explicit
    Const ERROR_SUCCESS As Long = 0
    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
    Sub testit()
      Dim flag1 As Boolean
      flag1 = DownloadFile("https://myportal.com/ZZDR6.csv", "c:\test.csv")
      If flag1 Then
        MsgBox "It downloaded the file"
      Else
        MsgBox "It didn't get the file"
      End If
    End Sub
    
    Function DownloadFile(s0 As String, s1 As String) As Boolean
       
       DownloadFile = URLDownloadToFile(0, s0, s1, 0, 0) = ERROR_SUCCESS
       
    End Function
    Best Regards
    MaczaQ
    ---------------------------------------------------------------------------------------------------------------------------
    If you are satisfied with the solution(s) provided, please mark your thread as Solved
    If you are pleased with my answer consider to rate it. To thank someone who has helped you, click on the star icon below their name.
    - This way you will add him some reputation points ... thanks in advance.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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