VBA - Workbook - path check if onedrive url working

vkingxl

New Member
Joined
Feb 2, 2020
Messages
4
Office Version
  1. 2010
Platform
  1. Windows
Hi All,

I'm trying to create a Kill code to protect my workbook if an employee leaves and takes a copy of our excel file. The excel file is saved on a cloud onedrive account, so if an employee leaves I can just change the onedrive password and they won't be able to access the file any longer, however if they obviously save the file to a USB stick then I can't really stop them from going to a competitor and using it.

I just want to make Workbook Open code, that checks when excel opens whether it can connect to the Onedrive cloud URL and view the file or not. With the password changed it should fail and then I will run a kill code or even just delete random formulas so the file will look legit at first but really be useless.

Here is what I was trying to test with but since the excel file is opened from the cloud and it's larger than 5MB it's automatically opened with the desktop app and must be saving it in a local cached folder somewhere. Is there another way I could accomplish my goal? The main idea is to be able to check if it can access the cloud directory/folder or not - not necessarily to confirm if this file is located there.

VBA Code:
      Dim fPath As String:      fPath = "https://d.docs.live.net/f......../" 'full path hidden for this post
  
   If ThisWorkbook.Path <> fPath Then
        MsgBox "No Access found"
   Else
        MsgBox "Access found"
   End If
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I had another thought - perhaps I could just tell the file to save to onedrive at the file open, since I already know how to do this - and if the upload fails due to network error it will kill the file.
 
Upvote 0

Forum statistics

Threads
1,223,231
Messages
6,170,884
Members
452,364
Latest member
springate

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