How to make self-modify Excel workbook in shared folder with read-only permissions? - excel

I made a workbook with VBA which is stored at shared folder of my employer. Employees can open this folder and workbook, but only as read-only.
User at this workbook works with several macros and I need to count number of starts these macros and store this data somewhere. In the best way, it will be stored in the workbook itself. But they do not have rights to modify the workbook, so they cannot save it even if I will try do it automatically as part of macro.
So what I need, is to find a way, how to make this workbook self editing (or auto-saving).
I found two possible ways, but they do not work at this scenario:
Because the file is opened just in read-only mode, I cannot save it directly. I even cannot use save-as and rewrite that file, because I haven't rights to editing it in that folder.
I found a way, where is new document in PC repository and the workbook saves data in that file and this file must be saved somewhere, where it could be editable. But I do not know networking enough to find a save place where I will make this file and even more, I am not sure, how will HQ looks at this type of activity.
I would prefer to count it in the file, but from MS support I get, that I cannot save it, just rewrite, which is impossible if I have not rights for that. So my question is, is there any save way how to count it or store data somewhere else?

As far as I know, without getting write-permissions fixed for your users, it can't be done. You should work with your network administrator to explain your requirements for the users.
Alternatively, you need to find a place where every user DOES have write-access, then design the script to save-as to that location. It all comes down to permissions.

Related

Prevent sending an opened excel document

Is there a possibilty to prevent a user from sending an excel document while it is still opened?
I had to make my document clear certain cells (containing personal data/personally identifiable information). I succesfully did this by using a function that generates a prompt before saving and only saves (and clears the respective fields) when accepting and doesnt do anything when canceling).
However, users can still send the opened document that contains the critical data.
I know it's a stretch, but is there a possibility to prevent this?
Like, with some sort of checksum/encryption shenanigans that corrupts the document while opened, thus rendering a sent copy in this state useless/not accessible/broken. The document would only be "fixed" again when saving (thus erasing the critical data too).
I can only imagine something like this, because forbidding other programs to read an opened excel document seems crazy.
Any help is greatly appreciated. Thanks in advance!
And hello to everyone here! (first post) This place is a lifesaver.
EDIT: For clarification:
1. Users get the excel document.
2. They enter personal data of staff/applicants etc. into it and my document does fancy stuff.
3. An output is generated which needs to go into some other tool.
4. The excel document's purpose is fulfilled and it must clean itself from filthy personal data.
This is achieved as described before. Saving etc. is all sorted out.
The problem I have been told to deal with, is to make it impossible to send the document while it still contains personal data. Closing wipes it, but while open, it still does contain personal data and can be interacted with Outlook etc.
Is there a way to prevent this kind of interaction with the document while still open? Or make the document corrupt while open, so copying it in this state won't transmit any personal data?
and welcome.
Your question is a bit of a strange one and I am not sure what would be the perfect way, but let me try answer and give you some suggestions:
A: You could work with a codeword in a specified cell. When you save a file it will put the word in that cell. When the word is not there.....well, let's say you can create some macro in Workbook.Open event that will delete all cellvalues and saves the file on its current location. Obviously put password on vba coding!
B: A more solid way in my opinion is to work on the file in your personal workspace if possible and upon saving the file create a copy to the shared folder through vba.
Good luck with it.
A: Manipulating the checksum/temp encryption would be quite risky since if your code crashes or is halted and closed the file is either corrupt or encrypted for you aswell, so information might be lost.
B: You could make the file copy to a temp while editing.
C: You can maybe block the save/autosave function of excel so that your editing won't get saved half-way in. (Not really a good solution, but a solution, likely quite easy).
EDIT:
For option C:
Insert this to workbook, it runs as it's named, before save.
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
//INSERT INSTRUCTION TO REMOVE PERSONAL DATA
End Sub
With this, data is removed before file is saved, so any saved state should be clean. Macro-deactivated workbooks however, cannot solve this problem, so you should maybe also add an event at workbook open that unlocks the sheets via VBA to avoid that flaw.

How to store macros in one file shared among several users? (not PERSONAL.xls)

I have a 20 excel files with Automation written in VBA where the workflow is similar but there is some customizations in each of the files. I would like to have 20 files, each file per task, but I would like to put all macros into one file, with all the customizations. This will simplify fixing/changing the automation.
I want to have basically one file GlobalMacros.xls somewhere in a shared drive which contains all the modules that do not contain customizations, and only have references to it in the proper files.
Personal.xls is not an answer as I do not want users/team members to feel the changes at all.
Please tell me if there is a solution and what are downsides.
Solution 1:
My solution is to make the module in GlobalMacro.xls and then add just a reference to the module in each file. The downside is it could slow down the execution of the macros because the GlobalMacros.xls will be opened and closed in the background each time any module is called out. Also is it possible for several users using these macros at the same time?
Has anyone got any better solutions? Maybe someone had a similar problem in the past.
I'll go into a bit more detail about how to use XLAM files properly.
In a network environment, you will want to keep a local copy of the XLAM where you make changes and updates, and once all glitches are worked out, you then copy it to the server where everyone else accesses it. You will want to also make the server copy read-only, which must be reset each time you copy the file to the server. If you dont make it read-only, you will not be able to copy the updated file to the server while anyone has Excel currently open.
In addition, when the users add the Add-On to their Excel, they will be prompted to copy the XLAM file to their local computer, to which they should reply No, as they want to be able to run off the server copy so they can get your updates. I have found that most people instinctively think they should answer Yes to that question.
If they end up answering Yes, then the only way to fix it is to edit thier registry and remove the reference, and then re-add the Add-On.

Manage external data source locations in Excel when sharing the file across Dropbox

When working in Excel, sometimes we have external data sources.
In Windows, these files may be stored in a specific location such as C:\Users\Freelensia\Dropbox\data source.xls
When sharing the main file and the data source file with another person through file-sharing services such as Dropbox, the location of the data source will be changed to:
C:\Users\PeterSmith\Dropbox\data source.xls
(from the view of the Peter Smith user)
This will break the data connection in the main file when Peter opens it. He can reset the path to the one as seen from his computer, but that will break the connection for the Freelensia user when he/she opens it from his/her end.
Is there a way to permanently fix these locations for multiple users? Such that Excel will correctly get the path when the right user opens it.
I am looking for an inherent Excel property if such a thing exists. Else VBA macros (A table with the file paths for each user, and MsgBox that ask the user to choose the user profile). Else a Windows .bat file could work as well.
Thank you for your help.
A trick to this is to move your Dropbox to C:\Dropbox for all users.
To do that, click on the Dropbox icon at the bottom-right, click the Gear Icon, Settings, Sync Tab, then you can move the folder to C:\Dropbox.
If you encounter permission errors, follow the instructions here to reset the permissions:
https://www.dropbox.com/help/desktop-web/move-dropbox-folder
If my understanding is right when ever a different user opens/saves a file the path "C:\Users\xxxxxxx\Dropbox\data source.xls" will be same only "xxxxxxx" in the path will be varying with the active user who has logged in.
So use "Application.UserName" function to get the username and use it in the path mentioned above
Excel uses relative links, even though it shows longer paths in the cells when you look at them. This ends up meaning that if you move the file and the file(s) it is connecting to a different location then the links will still work.
If you put your main file in Dropbox\Excel\main.xlsx and then your data sources in Dropbox\Excel\Data\data sources.xlsx then I think you should be good.
I tested this with Google Drive on two different computers, taking turns opening and modifying the data source and also opening and having the main file update without any issues.
I am not positive if this would work for you in Dropbox, but I really think it should... I am using Excel 2010, so if you are using Excel 2003 (or saving files as .xls instead of the newer .xlsx format) there is a possibility that could cause issues.

External Links not auto-updating when Source File is OPEN

I have a very odd occurrence happening. Linked data in a Master workbook is not updating when one of its source files are open. I have a Master workbook that has links to about two-dozen source workbooks. The links work properly when I open the Master file. However, if I open both the Master workbook and one of the source files and proceed to change one of the inputs from the source file, the update does not flow through to the Master file.
If I then save the source file and click Edit Links >> Update Values in the Connections section of the Data tab of the Master workbook, the data updates. I don't want to have to perform this manual "push" every time I update the source.
The only symptom I can find is that the reference to the source file in the Master file does not become an internal reference when the source workbook is open. It retains the entire file path (i.e. 'C:\shared\username\folder[filename.xlsm]sourcedata'!$D$3) instead of simply beginning with the bracketed expression ([filename.xlsm]sourcedata!$D$3).
Using Excel 2013.
This is only happening on my machine. I tried it on two other machines and the links work properly.
I have checked my calculation settings to automatic, and have Trust-Center set to the most permissive setting possible. I have automatic updating of links turned on. This workbook is password protected for EDITING (it can be viewed without a password).
Please help!!
This sounds like an issue I once had, I suggest you to try changing the file path syntax to UNC convention, i.e. instead of C:\shared\username\folder[filename.xlsm]sourcedata'!$D$3 something like: \\\ComputerName\C$\shared\username\folder[filename.xlsm]sourcedata'!$D$3
That sometimes helps

Recover unsaved .csv file changes

Does anyone know a way to recover changes made in a .csv that were not saved when excel 2007 was closed.
At the moment, I don't see any way to solve this.
Check all the temporary files created recently. Especially alongside the file you opened. There are a few temp folders in the system that Excel may use. C:\Windows\temp is the main one, but it is usually under the Users folder in later versions of windows. Eg: C:\Users\YourUserName\Local Settings\Temp
If you find any files that look like Excel temps, take a copy and rename the extension and then try to open it.
(Your only real chance is if auto-save kicked in and saved a copy - to a temp file - when you still had your new changes in the document. Otherwise the changes are lost I'm afraid)
If option #1 doesn't resolve your problem in Excel, go to File->Options->Save. Hopefully your AutoRecover file location, under the third box, will be populated with an address.

Resources