#1
|
|||
|
|||
Editing Word documents through VBA in SharePoint
I have word document with numerous command buttons on (with the VBA code for the click events being referenced in a template).
Each button has a different function but what they all pretty much share is that they will open other documents, edit them and then save/close. This all happens on our corporate network shared storage without any really intervention from the user, apart from clicking on the command button. We are in the process of moving to a cloud-based SharePoint Solution, which means that the vba code will now have to do the above from documents stored on SharePoint and not from network storage. I’m very new to SharePoint and I’m trying to adapt the code to work with SharePoint but I’ve hit a few issues that I just can’t seem to resolve/understand. So far, I have been able to open, edit and save/close a document using the following Code:
Dim docPath As String docPath = ActiveDocument.Path & "/workingpaper.docx" Documents.Open (docPath) With Documents("workingpaper ").Tables(4) .Cell(1, 1).Select Selection.TypeText "test" End With Documents("workingpaper ").Close (wdSaveChanges) The problem is that while the above is running, it is theoretically possible for someone to checkout the same document for editing. Therefore, I thought it would be best to check out the document in SharePoint rather than opening it, however this is where I hit a few problems. If I use Code:
Documents.CheckOut docPath The document flashes up on screen and then disappears. Then, no matter how I try and reference the document I always get a bad file name error, like once it’s checked out it can no longer find it. I certainly can’t see it on screen. As our current SharePoint solution which I am testing on is 2013 (moving to 2016 in the cloud), I understand that the document is only marked as checked out in SharePoint, rather than a local version being downloaded. My questions is once I have checked out a document using Code:
documents.checkout (File path) how do I reference/call this document so that I can do something with it such as edit the contents, check it back in etc. (the check in function also fails with the bad file name error). |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Documents spontaneously become "read only" while I'm editing them | Junebugsin | Word | 1 | 04-27-2018 06:39 PM |
Emailed documents locked for editing by someone else | jibbs | Office | 1 | 09-30-2015 05:12 AM |
Editing tables in restricted documents | Help_Needed | Word Tables | 4 | 09-29-2015 05:11 PM |
How to link word-documents i Sharepoint? | Katarina | Word | 0 | 03-24-2014 05:55 AM |
Linking word documents in sharepoint | tulip88 | Word | 1 | 04-05-2011 06:51 AM |