Access VBA linking to Sharepoint directory (1 Viewer)

Harris@Z

Registered User.
Local time
Today, 23:56
Joined
Oct 28, 2019
Messages
21
Hi all,

Hope someone can help - I have exhausted looking for a solution!

At present my Database creates a pdf report from a result and saves it to a OneDrive directory, which uploads the file into Sharepoint.

I would like to save the file directly to Sharepoint but have not fathomed out how to do so. I would also like to link to the Sharepoint directory and list files, the same way as I am able to on the OneDrive directory

I have tried doing a direct output to the Sharepoint directory, and also to map a drive to the Sharepoint directory (also failed)

For direct export, this is the last command:
DoCmd.OutputTo acOutputReport, SrcFile, acFormatPDF, DestPath & DestFile & ".pdf", ShowPdf, "", 0, acExportQualityPrint

The DestPath was to the local OneDrive on the server - which worked fine.

I have replaced the DestPath with DestPath = "https://xxxx610.sharepoint.com/:f:/g/EgTCQNQP0sJBuLBeUm8IKBUBr9tnBd9-TwxiyNz2exBY1w/ Password / EmailAddress"

(and tried without a password / email address)

Have also tried the direct url of "https://xxx610.sharepoint.com/Shared%20Documents/Forms/AllItems.aspx?viewid=00000000%2D0000%2D0000%2D0000%2D000000000000&id=%2FShared%20Documents%2FLab%2FeSig%5FTech2/"

Any ideas?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:56
Joined
Oct 29, 2018
Messages
14,939
Hi. Just as a test, are you able to map a drive manually to the SharePoint Library?
 

Harris@Z

Registered User.
Local time
Today, 23:56
Joined
Oct 28, 2019
Messages
21
Great question!
I tried again but am unable to.
I even followed advice from :/2017/01/20/how-to-map-your-sharepoint-online-library-like-a-network-drive/ (i am not allowed to post links!)

To no avail.
Tried shortening to https: //xxxxx610.sharepoint. /Shared[/Documents/Forms/AllItems.aspx

Message pops up "the folder you entered does not appear to be valid, even when I used the link to the folder I intended.

A puzzle!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:56
Joined
Oct 29, 2018
Messages
14,939
Great question!
I tried again but am unable to.
I even followed advice from :/2017/01/20/how-to-map-your-sharepoint-online-library-like-a-network-drive/ (i am not allowed to post links!)

To no avail.
Tried shortening to https: //xxxxx610.sharepoint. /Shared[/Documents/Forms/AllItems.aspx

Message pops up "the folder you entered does not appear to be valid, even when I used the link to the folder I intended.

A puzzle!


Hi. So, I think if you can't map to SharePoint manually, then you can't do it using code. It's either a matter of permission or it's not allowed (disabled) on your network system. Have you tried asking IT (if you have one) if this is possible/allowed?
 

Harris@Z

Registered User.
Local time
Today, 23:56
Joined
Oct 28, 2019
Messages
21
I have tried to ignore the websites advising how to link, and found that I can but it is counter intuitive. To map the drive, one has to not use the second part of the wizard, i.e., "Connect to a website that you can store your documents and pictures". One inputs the url in the 'folder' option. Then click both checkboxes, including the second which asks for "Connect using different credentials"

Then essentially, do not paste the link I showed above, but as if one were exploring a folder on your computer. In my case:
https:// xxxxx610.sharepoint. com/Shared Documents/Lab/

And viola, could map. Now to try this in Access
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:56
Joined
Oct 29, 2018
Messages
14,939
I have tried to ignore the websites advising how to link, and found that I can but it is counter intuitive. To map the drive, one has to not use the second part of the wizard, i.e., "Connect to a website that you can store your documents and pictures". One inputs the url in the 'folder' option. Then click both checkboxes, including the second which asks for "Connect using different credentials"

Then essentially, do not paste the link I showed above, but as if one were exploring a folder on your computer. In my case:
https:// xxxxx610.sharepoint. com/Shared Documents/Lab/

And viola, could map. Now to try this in Access
Okay, that sounds promising. If you can do it manually, then more than likely, you can do it using code too. Good luck!
 

Harris@Z

Registered User.
Local time
Today, 23:56
Joined
Oct 28, 2019
Messages
21
And to connect via VBA:
Shell "cmd.exe /k net use P: " & Chr(34) & "https://xxxxx610.sharepoint.com/Shared Documents/Lab/" & Chr(34), 0
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:56
Joined
Oct 29, 2018
Messages
14,939
And to connect via VBA:
Shell "cmd.exe /k net use P: " & Chr(34) & "https://xxxxx610.sharepoint.com/Shared Documents/Lab/" & Chr(34), 0
Excellent work! Good luck with your project.
 

Users who are viewing this thread

Top Bottom