Dear @Ivo,
Thank you for posting your question in the Microsoft Q&A forum.
Before giving you the best solution, could you please confirm these questions below to help me diagnose the issue more effectively:
- What version of Office/Excel are you using on each PC (e.g., Office 2016 vs Office 365)?
- Is the file stored in a personal OneDrive or OneDrive for Business?
- Could you please double-check whether the folder appTest is set to “Always keep on this device” on PC2? Open your OneDrive folder in File Explorer > Right-click the appTest folder > Select “Always keep on this device” from the context menu.
This ensures the folder and its contents are fully downloaded and stored locally. If the Office integration setting is also disabled, this should result in ThisWorkbook.Path returning a local path instead of a cloud URL. Always keeping the folder appTest synced locally on both PCs removes any ambiguity in path resolution
Moreover, since modifying the VBA code to handle OneDrive paths can get quite technical, especially if you're considering registry lookups or dynamic path conversion, I’d strongly encourage you to post your specific scenario on Stack Overflow.
- It is more suitable for publishing on Stack Overflow (English only).
- Post VBA programming questions to Stack Overflow by using the vba tag, along with any other relevant tags.
Disclaimer: Microsoft provides no assurances and/or warranties, implied or otherwise, and is not responsible for the information you receive from the third-party linked sites or any support related to technology.
You’ll get direct input from developers who’ve solved similar issues, and many have shared robust, reusable code for handling OneDrive’s URL-to-local path mapping in VBA. Then, clearly describe your setup (e.g., two PCs synced with OneDrive, VBA using ThisWorkbook.Path, differences in path behavior).
Please note that Stack Overflow has guidelines such as requiring a descriptive title, a complete and concise problem statement, and sufficient details to reproduce your issue. Feature requests or overly broad questions are considered off topic.
I hope this information is helpful. Please follow these steps and let me know if it works for you. If not, we can work together to resolve this.
Please understand that our initial response does not always resolve the issue immediately. However, with your help and more detailed information, we can work together to find a solution.
Thank you for your patience and your understanding. If you have any questions, please feel free to reach out.
I'm looking forward for your reply.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.