Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

LinkBack Thread Tools Display Modes
Old 09-26-2018, 05:23 AM
algecan algecan is offline Windows 10 Office 2016
Join Date: Sep 2018
Posts: 1
algecan is on a distinguished road
Default 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

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
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
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).
Reply With Quote

Thread Tools
Display Modes

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

All times are GMT -7. The time now is 01:40 AM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc. is not affiliated with Microsoft