大佬教程收集整理的这篇文章主要介绍了从 Excel VBA 在 OneDrive 上创建文本文件,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要使用活动工作簿的名称创建一个文本文件,但扩展名为 .txt。我使用以下代码:
Public Sub TEXTfile()
Dim fso As Variant,ts As Variant
Dim tempfilename As String
Set fso = CreateObject("ScripTing.fileSystemObject")
tempfilename = ActiveWorkbook.Fullname + ".txt"
DeBUG.Print tempfilename
Set ts = fso.CreateTextfile(tempfileName)
ts.Writeline "Hello"
ts.Close
End Sub
使用本地文件,它完美地工作。但是如果文件在 OneDrive 上,它会给出错误 52“错误的文件名或编号”。文件路径为:
xxx-my.sharepoint.com/personal/yyy_xxx_onmicrosoft_com/documents/test.xLSX.txt
关于如何解决这个问题的任何想法?
文件系统对象比 onedrive 旧得多,它不了解其路径。但是,如果您将 onedrive 文件夹同步到本地文件系统,例如:c:\users\name\onedrive...,您可以改用此本地路径,它会同步回 onedrive。
还有其他方法可以使用 onedrive api 将文件上传到 onedrive。然而,这些要复杂得多,并且需要一些身份验证知识 (https://docs.microsoft.com/en-us/onedrive/developer/rest-api/getTing-started/authentication?view=odsp-graph-onlinE)。 如果您愿意,请查看此处:https://docs.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitem_put_content?view=odsp-graph-online。
以上是大佬教程为你收集整理的从 Excel VBA 在 OneDrive 上创建文本文件全部内容,希望文章能够帮你解决从 Excel VBA 在 OneDrive 上创建文本文件所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。