Why do you think you need to do this? Typically all EPDM operations are unaware of what drive the local view is installed on.
I would need this for referencing in my excel.
I once tried to use the environment variables in VBA SolidWorks macro.
I do not remember why, but at me it did not turn out.
Perhaps because I wanted to place a macro in PDM. And maybe for other reason.
There can be what you want to make has alternative or ready solution in PDM?
What, specifically are you trying to do? If you're looking to create a hyperlink to a document in PDM, then you should probably read this:
Only thing you'd need to be able to do is to query your PDM database to find the IDs for the Project (folder) and Document.
In excel file I am trying to reference from another excel file that's on EPDM. But the fist excel file is also on epdm and it's used by everyone. However not everyone has the same EPDM path as other.
I think reading from registry is a solution. VBA seems to be able to do so.
In that case, it's actually much simpler than all that.
Per that old blog post I linked (from my VAR days):
- Every PDM installation has that custom URL protocol installed on it
- The only difficulty in using those hyperlinks is finding the Project ID and the Document ID for any given file. My recommendation:
- I'm not positive if you can link a SQL query to a card variable, if so: do this. Then your users can just look at a file card to get the values. Maybe you can even just create the hyperlinks in your card, then you can copy/paste into your xlsx files from there? I'd look into this if I still had access to PDM...
- Otherwise, just create an Excel File where you can customize a SQL query using cell values and distribute it to your team as a tool for creating hyperlinks URLs using the Conisio protocol.
- Let your users type in their file names (with extensions). If the unique file name option is engaged in your PDM vault, that's all the information that they need to enter. Otherwise, they would also need to copy + paste their folder path (without the root vault directory) to get the ProjectID.
- Your PDM database will have three tables that are worth searching in:
- dbo.Documents (Correlates file name- with extension- and the Document ID field)
- dbo.Projects (Correlates a folder path with its Project ID field)
- dbo.DocumentsInProjects (lists every Document ID and which Project ID it is stored in)
- Specific Queries worth using (its very basic, would need refinement if you don't have the unique file names option engaged in PDM):
- DocID = SELECT min [DocumentID] FROM [Documents] WHERE [Filename] = 'filename.xlsx'
- ProjID = SELECT DISTINCT [ProjectID] FROM [DocumentsInProjects] WHERE [DocumentID] = DocID ORDER BY [ProjectID] ASC
- Once you know the DocID and ProjectID for any given file, it's easy enough to use excel to concatenate the URL string per the blog post.
You can get the path to the vault root from the registry if you want:
HKLM\SOFTWARE\SolidWorks\Applications\PDMWorks Enterprise\Databases\<database name>\ShellRoot
Alternatively, you can use the PDM API method RootFolderPath.