简体   繁体   中英

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. 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.

You can use the ActiveWorkbook.path to get the path relative where your workbook is. You could also append & "/foldername" to get it from subfolders.

After trying few things this one I found most suitable to my requirements.

"Source= " & Application.ActiveWorkbook.FullName & ";".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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