VBA to Open Sharepoint file in Edit Mode

LONeill13

Board Regular
Joined
Feb 12, 2013
Messages
135
Hello: I see this question has been asked, but not yet answered.

I am trying to write code to open a file on our sharepoint site, but I can't seem to get the code to work.

Here is the code I am using:

VBA Code:
Private Sub UpdateFile(filepath As String)
Filename:="File Path/Report Name.xlsm"
    ActiveWorkbook.LockServerFile  'Edit Mode
End Sub

The error I get is Run-time Error '1004'
Method 'LockServerFile' of object' _Workbook' failed

Any assistance in helping me figure out how to get this to work would be appreciated.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
OK...I've been playing around with this all morning and I think it's because the file that I'm opening from Sharepoint is opening in a new window as opposed to the same window? I recorded a macro of me manually opening the Sharepoint file ("SharepointFile.xlsm) while another workbook is open ("OpenedFile.xlsm"), and when I toggled between the two it activates window as opposed to workbook.

VBA Code:
Sub Macro2()
'
' Macro2 Macro
'

'
    Workbooks.Open Filename:= _
        "http://sharepoint.com/sites/FilePath/Sharepoint File.xlsm"
    Windows("OpenedFile.xlsm").Activate
    Windows("Sharepoint File.xlsm").Activate
End Sub

Trying to figure out how to get the Sharepoint file to open up in the same window as the file that is already opened.
 
Upvote 0

Forum statistics

Threads
1,215,019
Messages
6,122,707
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top