I have thousands of documuments with associated metadata to upload to a library. Unfortunately I do not have the option of writing a program using the Server or Client Object Models, but I would still like to automate the process to the extent possible. I thought that I might use the Win32 API to populate the form controls and then submit the form, but the controls don't seem to have window handles, or I can't find them with Spy++.

Is it possible to programmatically populate form controls?

  • Have you tried automating SharePoint Designer, instead of the web interface? If you can't do it via the Win32 API, perhaps you could use image recognition to find the right place to move the mouse and click. AutoHotkey supports this, and there are even image-recognition tools out there.
    – jpaugh
    Sep 15 '17 at 14:23
  • I don't understand what you mean, but the users will not have SharePoint Designer. They will have only a browser. Even if image recognition helps me to click on a field, how would I set the text?
    – Anonymous
    Sep 15 '17 at 18:35
  • From your question, I assumed you were talking about a one-time upload by a single user (yourself). Perhaps a little more context would help?
    – jpaugh
    Sep 18 '17 at 16:07
  • The uploaders are regular users, i.e., not administartors or developers. A CSV file was prepared like this: Ahmad,Zia,...,Ahmad_Zia_001_blah-blah-blah.pdf with fields first_name, last_name, etc, and the last field is the \path\to\the\file.pdf. This was done on the assumption that they would be able to programmatically load that file into SharePoint but it seems that that option will not be available. I have to use a custom form that has some logic behind the scenes, and I am looking for a way to fill out the form without typing everything again.
    – Anonymous
    Sep 19 '17 at 11:18
  • There are web-automation tools, like Selenium and Phantom. However, if you already know CSOM, that would be easier than learning a new framework. You may be able to use AutoHotkey for this (as mentioned above), but it still requires learning a new language.
    – jpaugh
    Sep 19 '17 at 17:00

Please try these steps to upload the documents in bulk to SharePoint 2013 with associated metadata.

  1. Create the required metadata columns in the library. Example "First Name" and "Last Name".
  2. Upload the documents using "Open with Explorer" option in Library ribbon.
  3. Confirm the data in metadata columns.

Sample metadata columns in an Excel document

enter image description here

and here is the outcome after uploading to a library. The First and Last names come automatically.

enter image description here

  • Thanks. I should have mentioned that: 1) The metadata is in a CSV file like Ahmad,Zia,...,Ahmad_Zia_001.pdf.
    – Anonymous
    Sep 18 '17 at 8:17
  • 1) The documents are PDF and the metadata is in a CSV file like Ahmad,Zia,...,Ahmad_Zia_001_blah-blah-blah.pdf and 2) I must use the form because the form chooses the location (your files go to the "Z" library and the Ahmad_Zia_001 folder (001 is your unique ID). It also constructs the filename from the metadata.
    – Anonymous
    Sep 18 '17 at 8:28
  • @Anonymous, as the structural data is in the CSV file it can only be done using some custom code. The CSV can be read by System.IO and then you need to call CSOM or a server object model APIs to upload PDFs to the library. I would suggest you to create a simple console application to accomplish this. I am not sure if there are third party solutions out there to achieve this.
    – Ahmad Zia
    Sep 18 '17 at 12:17
  • Actually I have already written a working console program. For various reasons I will probably not be able to use it at this client so I was looking for a way to save my colleagues from typing everything that they already typed again.
    – Anonymous
    Sep 18 '17 at 20:18
  • @Anonymous, by the way what type of form is it? Is it an HTML form? In your console app, you can submit the form programmatically in a loop. Also just clarifying do you have that CSV (metadata) ready?
    – Ahmad Zia
    Sep 18 '17 at 23:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.