Our training courses

Other training resources

Our training venues

Why we are different

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 

Head office

Kingsmoor House

Railway Street

GLOSSOP

SK13 2AA

London

Landmark Offices

99 Bishopsgate

LONDON

EC2M 3XD

Manchester

Holiday Inn

25 Aytoun Street

MANCHESTER

M1 3AE

© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.

End of small page here
Please be aware that our website uses cookies!
I'm OK with this Tell me more ...