Save File in SharePoint Then Send Email

thrshr

New Member
Joined
Apr 24, 2020
Messages
3
Office Version
  1. 2013
Platform
  1. Windows
Hello,

I'm trying to setup a file that saves the data into directory in SharePoint but run into issues. Below is what I typically use to have the file saved to my computer just changed the path to the SharePoint site but it's giving me an error. Can you tell me what I'm doing wrong? Thanks so much in advance!

Sub Send_email()
Dim MailItem As Object
Dim MyPath As String
Dim MyFileName As String
Dim MyOutFile As String
Dim MyCopyRange As String
Dim MyLastDataRow As Integer
Dim MySheetName As String


EmailSendTo = ""
EmailBody = ""

Application.ScreenUpdating = False


MyPath = "//SharePointSite/sites/Directory1/SubD2/SubD3/Subd4/Subd5"
MyFileName = Range("N2")
MySheetName = "Manifest"

ActiveWorkbook.Sheets("Manifest").Select

If Not Right(MyPath, 1) = "/" Then MyPath = MyPath & "/"

MyOutFile = MyPath & MyFileName & ".xlsm"

ActiveWorkbook.SaveAs MyOutFile, FileFormat:=52

Application.DisplayAlerts = True

EmailSubject = "Email Subject " & MyFileName & ".xlsm"

Set MailObject = CreateObject("Outlook.Application")
Set MailItem = MailObject.CreateItem(0)

With MailItem
.Subject = EmailSubject
.Attachments.Add MyOutFile
.Display (True)

End With

TryAgain:

End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi

I don't use sharepoint so this is just something I 'think' I read somewhere.
Leave the ' ,FileFormat:=52 ' off the SaveAs line.
You already specified the extension in MyOutFile anyway so it is superfluous.

If it doesn't work out at least it bumps your post.
 
Upvote 0
This actually worked! Thank you so much for your help!
 
Upvote 0

Forum statistics

Threads
1,215,034
Messages
6,122,782
Members
449,095
Latest member
m_smith_solihull

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top