简体   繁体   English

在Excel VBA中获取使用“另存为”时使用的路径(从模板创建的文档!)

[英]In Excel VBA get the Path that is used when using “Save As” (document created from template!)

How can we get the suggested path that Excel gives when using "Save as" of a document that is created from a template on SharePoint? 当使用从SharePoint上的模板创建的文档的“另存为”时,我们如何获得Excel提供的建议路径? The document isn't saved so it doesn't have a path yet. 文档未保存,因此它还没有路径。 Although when we use "Save As" the correct document library is suggested in the Save window. 虽然当我们使用“另存为”时,会在“保存”窗口中建议使用正确的文档库。 We need that suggestion in VBA (to create a subfolder in that suggestion and save the document automatically by using a macro that runs on open). 我们在VBA中需要这个建议(在该建议中创建一个子文件夹并使用在open上运行的宏自动保存文档)。

Anyone who can help us finding the path property that is stored (and used while saving) on a document which is created using an Excel template through SharePoint? 有谁可以帮助我们找到在使用Excel模板通过SharePoint创建的文档中存储(并在保存时使用)的路径属性?

Extra info: We tried all things like Application.TemplatesPath, CurDir etc. It should be a property that SharePoint stores specifically in the document itself; 额外信息:我们尝试了所有的东西,如Application.TemplatesPath,CurDir等。它应该是SharePoint专门存储在文档中的属性; it isn't a last known location or something like that. 它不是最后一个已知位置或类似的东西。 We think so because we did several tests. 我们这么认为是因为我们做了几次测试。 When opening a file and close the internet connections; 打开文件并关闭互联网连接时; Excel tries to get connected to SharePoint and when it takes too long it shows the default location. Excel尝试连接到SharePoint,当它花费太长时间时,它会显示默认位置。 Also created a new document from template, saved another workbook in different local folder, afterwards save the template document and the suggestion is still correct. 还从模板创建了一个新文档,将另一个工作簿保存在不同的本地文件夹中,然后保存模板文档并且建议仍然正确。 We created a .xltm Excel template which now is the document template of a SharePoint content type. 我们创建了一个.xltm Excel模板,该模板现在是SharePoint内容类型的文档模板。 When we press the button "New document" button in de SharePoint ribbon, a new document is created. 当我们按de SharePoint功能区中的“新建文档”按钮按钮时,将创建一个新文档。

This started getting me to the right direction... Hopefully it helps 这开始让我走向正确的方向......希望它有所帮助

DefaultFilePath = ThisWorkbook.Path
If DefaultFilePath = "" Then DefaultFilePath = Application.DefaultFilePath
Application.FileDialog(msoFileDialogFilePicker).InitialFileName = DefaultFilePath
MsgBox (Application.FileDialog(msoFileDialogFilePicker).InitialFileName)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM