简体   繁体   English

如何在 VBA 项目中获取隐藏表的路径?

[英]How to get path of a hidden sheet in VBA project?

As I am trying to convert an xml response to recordset via hidden sheet.当我试图通过隐藏表将 xml 响应转换为记录集时。 I am saving that sheet in my project itself but while accessing that to convert it to recordset, I need its path.我将该表保存在我的项目本身中,但是在访问它以将其转换为记录集时,我需要它的路径。 Currently my path is system/user dependent but I want a generic path so that we need not to hardcode it each time we run the project in a different system.目前我的路径是系统/用户相关的,但我想要一个通用路径,这样我们每次在不同系统中运行项目时都不需要对其进行硬编码。 As my hidden sheet is being stored in my current work environment where my project is running, is it possible to get it without providing the full path?由于我的隐藏工作表存储在我当前运行项目的工作环境中,是否可以在不提供完整路径的情况下获取它? Current situation:Source=C:\Users\mycomputer\Desktop\Main Interface\MyProject.xlsm;" Desired situation: Source=(something independent of system)\MyProject.xlsm OR something like it.当前情况:Source=C:\Users\mycomputer\Desktop\Main Interface\MyProject.xlsm;" 所需情况:Source=(独立于系统的东西)\MyProject.xlsm 或类似的东西。

You can use the ActiveWorkbook.path to get the path relative where your workbook is.您可以使用ActiveWorkbook.path获取工作簿所在的相对路径。 You could also append & "/foldername" to get it from subfolders.您也可以 append & "/foldername" 从子文件夹中获取它。

After trying few things this one I found most suitable to my requirements.在尝试了几件事后,我发现最适合我的要求。

"Source= " & Application.ActiveWorkbook.FullName & ";". “源 =” & Application.ActiveWorkbook.FullName & “;”。

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

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