I was quite miffed that Malwarebytes identified my code as a virus. I had some Excel VBA macros that downloaded files from sharepoint in a fractoin of the time compared to opening them as a file from SharePoint. Brilliant … until “MalwareBytes just saved your life by killing Excel for you before you were doomed forever” … but … but hey – my program just poof … gone. Changes, long macro (that during VPN/Covid days) takes forever and now … gone. After some debugging it was the line URLDownloadToFile that paused Excel for about 4 minutes before then caused MalwareBytes to kill it. I did put in a ticket (and expect it to never be addressed) but suggested that if a file is in the trusted sites list – perhaps don’t view that as an exploit. It is likely faster to re-program things.
Suggestions online only have 3 options to download from SharePoint.
- map a drive, use the drive (and optionally kill the drive mapping). This seems lame. Plus you are opening a file using Explorer type access – which I said was slow
- Use URLDownloadToFile() which – EVERYONE IS USING – that is why it is likely why people who make viruses use it – it seems to be quite popular with Virus developers
- REST – way to complicated – no one has done it without asking for usernames and passwords everytime (I did figure it out – and this is how I am doing it now)
Alas – I DID figure out the bits and pieces to NOT as for credentials and to camp-out on an existing connection to SharePoint. I am doing this from an Excel VBA macro – so we are 99% guaranteed that we are connected. Complicated – you have no idea – YES IT IS.
Here is my journey:
Continue reading