Browse 545 attributed reviews, viewable separately for our classroom and online training

Details for Angel@86

Angel@86 has participated in the following threads:

Added by Angel@86 on 03 Jun 2021 at 07:16

Hi Andrew, Thanks for all those great explanations and videos you have on VBA scripting.Recently , i was trying to work on copyng an excel file from my Microsoft 365  sharepoint path to my local desktop folder.I have used the same code which you have explained in your video.But ,The file gets created in the respective local path .But , When i open the copied file its blanka nd it throws an error message "The excel cannot open this file "XXXXXXX.xlsx"because the fiel format or file extentionis not valid.Verify that the file has not been corrupted and that teh file extension matches the format of the file"

I have used the below code to copy file from sharepoint.

 Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" _
      Alias "URLDownloadToFileA" ( _
        ByVal pCaller As LongPtr, _
        ByVal szURL As String, _
        ByVal szFileName As String, _
        ByVal dwReserved As LongPtr, _
        ByVal lpfnCB As LongPtr _
      ) As Long
Sub URLDownloadURLWeb()

Dim FileURL As String
Dim DestinationFile As String

FileURL = "https://sharepoint.com/sites/WestESG/_layouts/15/Doc.aspx?sourcedoc=%7BDA181359-66E3-4C4F-BD2E-8E2DE44D5CB3%7D&file=Tracker_data.xlsx&action=default&mobileredirect=true&CT=1622699547701&OR=ItemsView"
DestinationFile = "C:\Desktop\macro\Tracler_Data.xlsx"

URLDownloadToFile 0, FileURL, DestinationFile, 0, 0


End Sub

 

Note: I have using Microsoft office 365 Proplus- Excel 

OS is a 64 bit

Kindly help me in sorting this issue