u/hellcryer

Power Automate: Save email attachments directly to network share instead of SharePoint?

Hi everyone,

I have a completed flow for the following scenario:

  • A new email arrives in a shared mailbox.
  • Power Automate checks whether the email has attachments.
  • If attachments exist, save them automatically.

Currently, I'm saving the attachments to SharePoint, and this works fine because it's a standard Power Automate setup. However, we're starting to face limitations with SharePoint libraries due to the volume of files being stored.

My alternative goal right now is to save the attachments directly to:

  • A network/shared drive

The challenge is that these files need to be accessible by many users, so OneDrive is not a suitable option.

I've also tried using the File System connector with an On-Premises Data Gateway, but when I run the flow, I receive the following error:

>

Because of this, the File System approach appears to be blocked by company policy.

Has anyone faced a similar situation?

Are there any alternative solutions to automatically save email attachments from Power Automate to shared/network drive without using OneDrive and without violating DLP policies?

Any suggestions would be greatly appreciated.

Thanks in advance!

reddit.com
u/hellcryer — 3 days ago
▲ 6 r/vba

Issue with VBA to download SharePoint files

Hi all,

I’m running into an issue with a VBA script that downloads files from a SharePoint folder using the REST API.

Most of the time, the code works perfectly, it connects, retrieves the file list, and downloads everything without any issue.

But randomly, I get this error:

MsgBox "Failed to connect to SharePoint API", vbCritical

This happens when the XMLHTTP request does not return status 200.

The confusing part is:

  • I can still open the SharePoint site manually in my browser without any issue
  • No changes in URL or permissions
  • Same code, same machine

So I don’t understand why the connection sometimes fails and sometimes works fine.

My setup:

  • Using MSXML2.XMLHTTP to call SharePoint REST API
  • Using URLDownloadToFile to download files
  • No explicit authentication handled in VBA (relying on logged-in session)

If this approach is fundamentally unreliable, I’m open to switching methods but still prefer to use in VBA

Below i provide full code setup to review.

Option Explicit

#If VBA7 Then

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

#Else

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

#End If

Sub Download_All_From_SharePoint()

Dim apiURL As String

Dim json As String

Dim xmlhttp As Object

Dim saveFolder As String

Dim fileName As String

Dim fileURL As String

Dim arr() As String

Dim i As Long

apiURL = "https://TEST.sharepoint.com/sites/TEST/TEST/_api/web/GetFolderByServerRelativeUrl('/sites/TEST/TEST/TEST/TEST/Confirming Temp')/Files"

saveFolder = "C:\Temp\CONFIRMING\"

If Dir(saveFolder, vbDirectory) = "" Then MkDir saveFolder

Set xmlhttp = CreateObject("MSXML2.XMLHTTP")

xmlhttp.Open "GET", apiURL, False

xmlhttp.setRequestHeader "Accept", "application/json"

xmlhttp.Send

If xmlhttp.Status <> 200 Then

MsgBox "Failed to connect to SharePoint API", vbCritical

Exit Sub

End If

json = xmlhttp.ResponseText

arr = Split(json, """Name"":""")

For i = 1 To UBound(arr)

fileName = Split(arr(i), """")(0)

fileURL = "https://TEST.sharepoint.com/sites/TEST/TEST/TEST/TEST/Confirming Temp/" & Replace(fileName, " ", "%20") & "?download=1"

If URLDownloadToFile(0, fileURL, saveFolder & fileName, 0, 0) = 0 Then

Debug.Print "Downloaded: " & fileName

Else

Debug.Print "FAILED: " & fileName

End If

Next i

MsgBox "All files downloaded!", vbInformation

End Sub

reddit.com
u/hellcryer — 11 days ago
▲ 13 r/vba

How to connect VBA to Copilot (or any AI) to process PDF and return extracted data?

Hi all,

I’m currently working heavily with VBA automation (Excel/Outlook/SAP workflows), and I’m exploring ways to integrate AI (specifically Microsoft Copilot or similar AI services) directly into VBA.

Goal:
I want to achieve something like this:

  1. From VBA, send a PDF file
  2. Pass it to Copilot (or any AI API)
  3. Let AI extract specific information (e.g., invoice number, amount, date, etc.)
  4. Return the extracted data back into Excel

Example flow = VBA → Send PDF → Copilot → Extract data → Return JSON/text → VBA → Populate Excel

My questions:

  • Is it possible to directly connect VBA to Microsoft Copilot?
  • If not, what’s the recommended approach?

What I’ve so far:

  • Using PDF to word and to text - Not very good approach due to a lot of different format and shapes.
  • PDF to Text open sources - can't use due to company policies.

But I’m not sure what the best / supported approach is today.

Constraints:

  • Prefer to trigger everything from VBA (button/macro)

Thanks in advance!

reddit.com
u/hellcryer — 1 month ago

Hi everyone,

I have a Power Automate flow that works perfectly when a new email arrives in the Inbox of a shared mailbox.

Now, I’d like to change the process slightly. Instead of triggering when an email arrives in the Inbox, I want it to trigger flow to run the email flow into a specific subfolder under the Inbox which is only after a user manually moves the email.

In other words:

  • User receives an email in the shared mailbox Inbox
  • User moves the email to a specific subfolder
  • The flow triggers when a new email appears in that subfolder

Is this possible in Power Automate?
If so, what’s the recommended approach or workaround?

Thanks in advance for any advice or best practices.

reddit.com
u/hellcryer — 2 months ago