I frequently open large excel files (100 MB+) from a network location that I completely trust. However, the default trusted domains on the workstation that I use does not include files on the network drive. It is cumbersome to load each excel file twice (once to open it from explorer, then again to 'enable editing', i.e. remove protected view).
Is there an argument/switch that can be provided to excel.exe from the command line that will force a file to be opened in unprotected(editable) view? I would find this less cumbersome than waiting for a large file to load twice.
I typically use Excel 2010 and 2013.
Note: I already know how to disable protected view through the excel interface, this is not the solution I am looking for, as these settings reset to their defaults everytime I log off the workstation.
I am also prepared to accept the fact that this might not be possible to do except in the Excel GUI. But if anyone has a workable solution, that would be brilliant. Thank you!
Is there an argument/switch that can be provided to excel.exe from the command line that will force a file to be opened in unprotected(editable) view?
No.
The protected view comes as a result of the level in the security settings, thus it would be a major security problem, if it can be avoided.
As a possible workaround - copy the files to your computer, mark it as trusted and open them there.
Related
I'm encountering an issue trying to get some macros and VBA scripts working on a new coworker's computer. I've been using the same code for years on my machine and several others without issue, but when my new analyst tries to run it, it throws an error stating it couldn't save the file. He can manually save the file without issue, but running the script throws the error. The really weird part is that it lists the file path, but replaces the filename with a seemingly random hex byte.
On another file, if he opens it, closes with or without saving, then I open the file and try to save it using a macro, it fails saying "cannot access file...". If I copy and paste the file, open and run the macro again, it saves over the offending file no problem.
We've checked permissions and settings and haven't found anything that was different between the two systems. We're both on VMs. His hardware allowance is less than mine but otherwise they're both IT-managed and identical. I'm at my wits' end... Any advice on what may be the source of my grief would be helpful, even if not a solution.
A couple of things I'd check before trying to step through debugger mode.
Coworker does not have write access to the directory (I think you said you checked already)
The new users' Trust Center Settings are not correct
File > Options > Trust Center > Trust Center Settings... > Macro Settings > Ensure the box is checked to trust the VBA model and that macros are not disabled
The new user does not have the same libraries referenced.
Alt + F11 > Tools > References... > Check if coworkers' libs match yours
Is he using a new/different version of Excel that you? A lot of older code got bojangled when Office 365 hit the scene.
After checking settings, I would ask the following:
What error is thrown when coworker attempts to run the macro?
When does the error get thrown? It could be that you have code that is attempting to edit the file (or has another file stuck in an edit) at the same time you're trying to save it.
I would see why the file name is getting corrupted. It sounds like coworkers' machine is looking to a bit of memory or memory address that is somehow getting forgotten. Like the code is referencing a variable that is out of scope.
User Access Control has been enabled on his VM that is somehow preventing him from saving the file correctly.
Your code does not properly Quit the Excel application, so its still running in the background on coworkers' machine. Have them open/close without saving a file and check Task Manager to see if Excel is still up to confirm
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.
No doubt a very easy fix that someone here has come across before...
I have an Excel macro enabled file (.xlsm) that has some VBA to make graphs, pick data, get data, scale axes etcetera however 75% of the time when I open the file it says that another user has the file open and will be read only.
I've checked very carefully and I'm definitely the only user with the file open. The same thing occurs if the file is located either on the hard drive of this computer or if I load it from a server.
If the file is saved as a .xls file the problem never occurs, up to date at least.
Adding "End" to the VBA code seemingly has no effect.
I can only assume from my above tests that it is something in the VBA part of the file that causes this issue. Any help would be much appreciated.
Some thought:
1) Check your code to see if at any point, you have the file open (workbook.open to current file)
2) Is the file on a network?
3) Check the .xlsm's properity if it is read-only
4) Go to Option - Trust Center - Trust Center setting to see if macro is enabled.
These are Excel settings for the computer. If you go to the File tab on the ribbon, Excel options and go to Trust Center > Trust Center Settings you can modify this.
You can set the trusted locations documents or publishers. Also check macro settings and protection.
I work on a custom project system and I have an issue with renaming items. The project system implementation is based on MPF and renaming items via the solution explorer worked more or less without any problems, but...
When an item gets renamed, I also update information which are stored in the file itself. In case the document is opened by the code editor, the text in the editor doesn´t get refreshed (only the document window´s caption changes to the new filename). If I save the open document all changes applied by the rename operation are overriden, of course.
How can I force the editor to reload the document, so that the automatic changes will be shown?
Assuming it's a text file versus some custom designer, use the IVsRunningDocumentTable interfaces to get the text buffer for the file that's currently open. The fourth iteration of the interface is the easiest one to use from managed code. You can call IsMonikerValid (where the "moniker" is the file name) to see if the file is open, and if so then call GetDocumentData to get the IVsTextBuffer for the file. That type itself is fairly annoying to work with, so if you're only supporting Visual Studio 2010 or later, then pass that to this function to get the newer editor APIs version of it.
As far as they "why" it's a good idea to do this: if you edit the file on disk and then try to force a reload, there are various problems you might run into. If the file wasn't saved before the rename, you might accidentally lose those unsaved edits. The reload might cause the undo history of the file to be lost, and any other extensions/features that were tracking points in the file with editor tracking spans or markers might lose the points they're tracking. Performance should be a bit better too if the file is a large file.
I'm using powershell to export-csv a table. If the csv file is open anywhere on the network, the script will not overwrite the file. Is there anyway to work around this?
You would need to change how the network deals with users opening the files.
Usually, when a user (who is not an admin) opens a file on the network, you want the user to open it as read-only.
Only then, you will be able to overwrite the file using your script (with admin privs ofc)
If you do not have control over the network, the best option would be to create a different file with the same name but with revision number at the end. For example, "a.csv" would become "a001.csv" after the first edit.
Because of the nature of the solution, it will create havoc if multiple users are working on the same file.
In this case, I would suggest looking at version control softwares... But then again, it would be silly to go through all this for just editing a simple .csv file.. So, the answer is "it's complicated"