Application.Workbook.Path issue

acarrigan

New Member
Joined
Nov 23, 2024
Messages
3
Office Version
  1. 2016
Platform
  1. Windows
I am moving an application from a PC to Server
I have a macro that runs the Application.Workbook.Path command.
On the PC, I get this result: H:\SAPReports
On the Server, I get this result: \\merfile-01\is\SAPReports
Even crazier to me. I've been running the macro on the server for weeks without issue.
I only started getting different results today.
What is the "standard" result supposed to be?
Drive Path or UNCPath?
 

Attachments

  • PC.jpg
    PC.jpg
    7.4 KB · Views: 8
  • Server.png
    Server.png
    3 KB · Views: 8

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
AFAIK you can't go wrong using a UNC path. Drive letters are only volume labels on a drive. You can have H mapped to one server, and a colleague can have H mapped to a different server. So how do you code for each one referring to the same path to a file/reference? By using a UNC path - then the drive letter doesn't matter. So if you used the server name/path in both scenarios there would be no need to change anything wrt file paths when you publish your app to where everyone can use it.
 
Upvote 0
Thanks for the reply perhaps I wasn't clear enough on the problem. I agree UNCPath is the best course and that is what I am trying to do.
My question is why does ActiveWorkbook.Path return the drive letter on one machine and on another machine the UNCPath.
I have already addressed the issue by testing what is returned and converting to the proper UNCPath.
Now just curious as to how ActiveWorkbook.Path can return different results - machine based? excel version?
What's worse one day it was returning the drive letter the next day the UNCPath.
I may ne naieve but doesn't seem like that should happen.
Thanks
 
Upvote 0
Sorry, I don't know the reason, especially if it flip flops on the same pc/server. If you're using the result in code I suspect it would not matter what was returned if you passed the string to a variable - unless it matters to you if it starts with H or not. Perhaps test using ServerName. I would have tried that before suggesting it, but I have no access to a network.
 
Upvote 0

Forum statistics

Threads
1,223,996
Messages
6,175,867
Members
452,678
Latest member
will_simmo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top