从Excel VBA间歇性打开SharePoint文件 [英] Intermittent opening SharePoint file from Excel VBA

查看:269
本文介绍了从Excel VBA间歇性打开SharePoint文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



大部分都是"我不知道我不知道的"如果我没有提供足够的信息,请原谅。



我在SharePoint上有一个Excel文件,我在本地Excel文档上使用VBA打开。 SharePoint站点要求用户在VBA打开文件之前登录。但是我的用户抱怨说,即使他们登录到SharePoint
网站,有时该文件也无法打开。似乎没有任何合理的押韵。



我注意到,如果我们转到SharePoint文件夹,该文件位于使用Internet Explorer并单击"在文件资源管理器中打开",对于大多数人(如果不是全部的话)来说,这个问题似乎很明显,并且突然代码工作正常。



认证?由于问题出现并且似乎只影响一些用户,我不知道如何确定原因,更不用说解决方法了。



也许这个问题以前见过什么?
$


谢谢!

解决方案


您可以尝试使用以下代码使用VBA打开位于SharePoint库文件夹中的Excel文件:

 Dim SummaryWB As Workbook 
Dim vrtSelectedItem As Variant

使用Application.FileDialog(msoFileDialogOpen)
.InitialFileName =" https://sharepoint.com/team/folder" &安培; " \"
.AllowMultiSelect = False
。显示
每个vrtSelectedItem In .SelectedItems
设置SummaryWB = Workbooks.Open(vrtSelectedItem)
下一个
以$ b结尾
$ b如果SummaryWB为Nothing,则退出Sub

从SharePoint打开Excel文件


谢谢


最好的问候


Hello,

Much of this is a "I don't know what I don't know" so excuse me if I don't provide enough information.

I have an Excel file on SharePoint that I open using VBA on a local Excel document. The SharePoint site requires the user to be signed in before the VBA can open the file. However my users are complaining that even though they are logged into the SharePoint site, sometime the file will not open. There doesn't seem to be any rhyme of reason to it.

I noticed that if we go to the SharePoint folder the file is located on using Internet Explorer and click "Open in File Explorer", the issue seems to clear for most, if not all, people, and suddenly the code works fine.

Is something wonky with the authentication? Since the issue comes and goes, and seems to only affect some users, I have no idea how to nail down the cause, let alone a workaround.

Perhaps this issue has been seen before?

Thank you!

解决方案

Hi,

You can try to use the following code to open excel file located in a SharePoint library folder using VBA:

Dim SummaryWB As Workbook
Dim vrtSelectedItem As Variant

With Application.FileDialog(msoFileDialogOpen)
    .InitialFileName = "https://sharepoint.com/team/folder" & "\"
    .AllowMultiSelect = False
    .Show
    For Each vrtSelectedItem In .SelectedItems
        Set SummaryWB = Workbooks.Open(vrtSelectedItem)
    Next
End With

If SummaryWB Is Nothing then Exit Sub

Open Excel file from SharePoint

Thanks

Best Regards


这篇关于从Excel VBA间歇性打开SharePoint文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆