WS
asked on
MS Access - Form - Upload document to Sharepoint form Access Form
Hi,
I have a Access database and a Sharepoint folder (with subfolders also) to store documents. I have a table that store all the metadata for document in Access. I want to create a form that upload document to Sharepoint specific folder. How could that be achieve through form? Is there any build in ways to do that? or do i have to write a VBA Code to get document form some location and then upload to a specific related folder in sharepoint?How that could be achieve?
Any help would be appreciated.
Thank you.
I have a Access database and a Sharepoint folder (with subfolders also) to store documents. I have a table that store all the metadata for document in Access. I want to create a form that upload document to Sharepoint specific folder. How could that be achieve through form? Is there any build in ways to do that? or do i have to write a VBA Code to get document form some location and then upload to a specific related folder in sharepoint?How that could be achieve?
Any help would be appreciated.
Thank you.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Go to Tools, References and add a reference to Microsoft Office 16.0 Object Library
/gustav
/gustav
ASKER
Skip that - store the filename in a string variable:
FileName = .SelectedItems.Item(1)
Then use FileCopy to copy the file.
/gustav
FileName = .SelectedItems.Item(1)
Then use FileCopy to copy the file.
/gustav
ASKER
I think i didn't explain well, there is a button a form as upload , there are two textbox as targetLocation and DestinationLocation. I want that when the user click on TargetLocation it should show something like this , user will select some document either pdf or word or excel or image, will click open and that location or path will be shown in target textbox. Then it will click on upload button and something should like this show where the user will select the destination location and will upload.
in my question where i mention
The purpose of this form is to upload document from desktop/document somewhere to Sharepoint document library that is mapped in my local PC.
Any code to achieve this?
Thank you.
in my question where i mention
Code to get document form some location and then upload to a specific related folderi mean all this.
The purpose of this form is to upload document from desktop/document somewhere to Sharepoint document library that is mapped in my local PC.
Any code to achieve this?
Thank you.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
' This requires a reference to the Microsoft Office xx.0 Object Library. "xx = your office versionThis was in the code I posted.
Me.txtFilePath is the name of a control on the form. You could use a variable if you want to. In my case, I was using a bound form and I wanted to save the path so I put the selected path into a control so it could be saved.
You need two controls. One to pick the source DOCUMENT so you need to use --
Use msoFileDialogFilePicker if you want a file list rather than a folder listfor that text box. Then use the sample code to pick the folder for the target.
The last step is to use
FileCopy Me.txtSourceFile, Me.txtSourceFolder
To copy the file.
ASKER
Thank you Gustav and PatHartman, and sorry for taking long to reply as i was setting up all the other requirements also. Gustav , the code you wrote works well there is just one thing in that if you could help me in that as there are two fields in my table as Root Link and Target Link, Target link will get the path from txtTarget but i want that half of the link be saved in Root Link and half in Target Link. For example my link for Sharepoint is D:/Data/USA/2015, I want that the root link which is D:/Data( which will be same for all) should be save in Root Link and USA/2015 save in Target Link.
Also if you guys could guide me that the link which is there in Target Link field in table doesn't open like when click on that it should open that document but it's working , any idea why?
Also if you guys could guide me that the link which is there in Target Link field in table doesn't open like when click on that it should open that document but it's working , any idea why?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Gustav, some error pops up when i try to upload document into sharepoint folder (sharepoint server folder that is map to my local PC), to copy document from one file to another it work but to Share point folder it's not working it's giving error as shown in image.
When i copy document from one folder to another locally it's working , but to Sharepoint server/Sharepoint folder map to PC ,it is not working.
Any help?
error1.png
When i copy document from one folder to another locally it's working , but to Sharepoint server/Sharepoint folder map to PC ,it is not working.
Any help?
error1.png
Can't tell. Here I can copy to one of our Sharepoint folders just like that - as to any local or network folder, like:
C:\Users\Gustav\OneDrive - Cactus Data ApS\Attached Files\Test.txt
/gustav
ASKER
don't we need any line of code to upload document to Server?
No. It is here:
FileCopy Me!txtSource.Value, Me!txtTarget.Value
/gustav
ASKER
FileCopy Me!txtSource.Value, Me!txtTarget.ValueThe error which i mention is also in the same line which is copying the document to Sharepoint Server.
Also For one drive it's working. In my One Drive also it is uploading but in Sharepoint Server it is not uploading.
I tried using the field attachment also it is also not uploading in the Sharepoint mapped Folder.
I tried that - to the synchronised folder - and it worked with zero issues:
/gustav
C:\Users\Gustav\Cactus Data ApS\Test - General\Testing.xlsm
Maybe you haven't been granted rights to save to such a location?/gustav
ASKER
i'm the Site Owner for this document library in Sharepoint Server so i have the rights.
I'm still not able to get why this is giving the error i mention in this code for me.
Can i break this code to see error? If yes, how?
I'm still not able to get why this is giving the error i mention in this code for me.
Can i break this code to see error? If yes, how?
There is only this single line of code.
What does your target path look like?
/gustav
What does your target path look like?
/gustav
ASKER
this is how my target path look like: https://res.abc.org/St/Doc/D/ABW/abc
Yes, that won't work. You must have a mapped drive or a UNC path for FileCopy to work.
Synchronise the folder (or a parent folder) with your desktop, and then use the desktop folder path as target.
/gustav
Synchronise the folder (or a parent folder) with your desktop, and then use the desktop folder path as target.
/gustav
ASKER
Gustav, can you explain a bit more because i am new to this.
What i have done is i open with Explorer from Sharepoint and then i add it as favorite and then it is there as folder under favorite field.
What's the difference between mapping and adding it like this, as i see they both work the same way.
error1.png
What i have done is i open with Explorer from Sharepoint and then i add it as favorite and then it is there as folder under favorite field.
What's the difference between mapping and adding it like this, as i see they both work the same way.
error1.png
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Gustav this is the Sharepoint in Cloud, but i have Sharepoint Server like which is wihtin the organization in that you can't Sync.
Oh, then you must discuss your options with your admin.
/gustav
/gustav
ASKER
i discuss with them and what they recommended is that there will be a code that will upload document to Server. The one code above it will work for folder , for Server few more lines have to be added , do you have any idea how to add server path?
FileCopy will accept a UNC path, something like:
\\servername\folder\St\Doc \D\ABW\abc
if that is what they mean. If not, another file copy method must be used.
/gustav
\\servername\folder\St\Doc
if that is what they mean. If not, another file copy method must be used.
/gustav
ASKER
do you have any idea how to use other method?
The code you provided is what i want and it work also it's just this one error that i am not able to resolve.
Untitled.png
The code you provided is what i want and it work also it's just this one error that i am not able to resolve.
Untitled.png
I located this blog post which seems to list your alternatives:
Uploading Content Into SharePoint
Still, if you can obtain a UNC path to the folder, that's the simple method.
/gustav
Uploading Content Into SharePoint
Still, if you can obtain a UNC path to the folder, that's the simple method.
/gustav
ASKER
From where could i obtain UNC path?
From your Sharepoint administrator.
/gustav
/gustav
First, use Application.FileDialog to select the file.
Next, use VBA.FileCopy to copy the file to your Sharepoint folder.
Finally, save the full path in your table.
/gustav