打开位于一个驱动器中的Excel文件

gupuwyp2  于 2023-02-05  发布在  其他
关注(0)|答案(1)|浏览(156)

我需要使用Excel打开位于共享点的Excel文件。应用程序
在Visual Basic 6中,我使用以下命令打开Sharepoint中的excel文件:

Shell "C:\Program Files\Microsoft Office\root\Office16\EXCEL.EXE https://livecnm-my.sharepoint.com/:x:/g/personal/sghimire_cnm_edu/EZwyv4Ot1_xEnIeT1SIADncBVtRQ0b6THoJj0eLrbpEjXQ?e=NgyEBD", vbNormalFocus

但我想使用Excel。应用程序,而不是 shell ,所以,我可以隐藏功能区,状态栏,公式栏和Excel文件打开前的其他东西。我已经尝试了以下,但它不工作:

Dim xlApp As Object
Set xlApp = CreateObject("Excel.Application")

With xlApp
.Workbooks.Open "https://livecnm-my.sharepoint.com/:x:/g/personal/sghimire_cnm_edu/EZwyv4Ot1_xEnIeT1SIADncBVtRQ0b6THoJj0eLrbpEjXQ?e=NgyEBD"
.Application.ExecuteExcel4Macro "Show.toolbar(""Ribbon"",False)"
.Application.DisplayStatusBar = False
.Application.DisplayFormulaBar = False
.Application.DisplayScrollBars = True
.Application.Visible = True

End With
s4n0splo

s4n0splo1#

也许你给予试试

Sub open_excel_from_one_drive()
    Dim sfilename As String
    Dim xl As Excel.Application
    Dim xlsheet As Workbook

    sfilename = "https://d.docs.live.net/78a58439bd7a4267/Investment%20Spreadsheet/Customer%20Management/Security%20Data.xlsm"
    Set xl = Application
    Set xlsheet = xl.Workbooks.Open(Filename:=sfilename)

End Sub

如果您想继续使用您的代码,那么您可以尝试

Sub dummy_Code()
    Dim xlApp As Object
    Set xlApp = CreateObject("Excel.Application")

    With xlApp
        .Workbooks.Open "https://d.docs.live.net/78a58439bd7a4267/Investment%20Spreadsheet/Customer%20Management/Security%20Data.xlsm"
        .Application.ExecuteExcel4Macro "Show.toolbar(""Ribbon"",False)"
        .Application.DisplayStatusBar = False
        .Application.DisplayFormulaBar = False
        .Application.DisplayScrollBars = True
        .Application.Visible = True

    End With
End Sub

相关问题