使用动态文件名保存到 SharePoint 的 VBA 宏 [英] VBA Macro to Save to SharePoint with dynamic file name
问题描述
我有一个 Excel 工作表,我想通过宏将其保存到 SharePoint.我已经排序了,但问题是每个月的文件名都会不同,我不想每次都更改宏(即 filenameSeptember、filenameOctober 等).
I've got an excel sheet that I want to save to SharePoint via a macro. I have it sorted, but the problem is every month the file name is going to be different and I don't want to have to change the macro each time (i.e. filenameSeptember, filenameOctober, etc).
我正在使用一个非常基本的宏,因为我不太擅长编写它们,它可以工作,但它硬编码了旧文件名:
I'm using a very basic macro because I'm not super good at writing them, and it works but it's got the old filename hardcoded in:
Sub savetest()
ActiveWorkbook.SaveAs Filename:= _
"http://SharePointdirectory/filenameSeptember.xlsm" _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
End Sub
上下文:每个月我都会用新数据更新这个文件并用新文件名保存它,将它发送给用户进行验证 - 我希望这个用户能够通过一个宏直接上传到 SP 目录自动使用我称之为文件的文件名.
Context: each month I would be updating this file with new data and saving it with a new filename, sending it to a user to validate - i want this user to be able to upload directly to the SP directory via a macro that automatically uses the filename i've called the file.
我希望这是有道理的,并提前致谢.
I hope that makes sense, and thanks in advance.
推荐答案
我最终使用单元格来指定文件名并存储路径,这似乎有效:
I ended up using cells to specify a filename and store the path instead, which seems to work:
Public Sub SavetoSP()
ThisFile = Range("D1").Value
ThisPath = Range("J1").Value
ActiveWorkbook.SaveAs Filename:=ThisPath & ThisFile & ".xlsm"
End Sub
这篇关于使用动态文件名保存到 SharePoint 的 VBA 宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!