I have an Excel file that's linked to a SQL database view. The Excel file needs some monthly massaging that I am trying to do with a VBScript but this dialog box keeps coming up and interrupting my VBScript:
This workbook contains links to one or more external sources that could be unsafe.
If you trust the links, update them to get the latest data. Otherwise, you can keep working with the data you have.
And buttons for Update, Don't Update and Help
I do trust the data (it's our on-site SQL server), I don't want to refresh the data with this specific script (it takes about 15 minutes and it is refreshed via another process). But the dialog box is holding up my whole VBScript, how do I dismiss it? I've tried ExcelObj.DisplayAlerts = False and ExcelObj.EnableEvents = False but neither is making this dialog box go away. Please help!
Related
I have an excel workbook that is to be used as a report, that is distributed to different people. The workbook gets data from an input file (another Excel file) that is not available to all the people who are receiving the report.
My problem is, that when the people who does not have access to the input file opens the report, the workbook tries to update the data, but fails, as the user does not have access to the input file. Is there a way to stop the sheet from auto-updating when it is opened?
Based on the versions of excel I have used, Excel 2013 and 2016 that does not sound like the standard behavior I have seen.
There would be a couple things to check:
1) Is there macros in the file, which run on open and force refresh. VBA command to refresh a data model being the following ThisWorkbook.Model.Refresh
2) Right click on the pivot tables --> Pivot table settings --> Data, check if refresh data when opening the file is selected. Not sure on this one but it might be forcing a refresh of the model.
3) If you are using power query, open the queries & connection tab, right click each query and select properties. There is an option for Refresh data when opening the file.
I've written a script that builds excel reports. These reports may include pivot tables. To refresh a pivot table on load, I added refreshOnLoad="1" parameter to pivotCacheDefinition1.xml file. It works good with only one minor thing that I do not like - when I open a report, excel asks me "do you want to replace the contents of the destination cells"? I press "ok" and it refreshes pivot tables. I do not like this pop-up window with this question, and I think it's obvious that if refreshOnLoad="1" is specified then contents should always be refreshed. So, my question is how to suppress this window from popping up?
EDIT
According to this thread:
Whenever Excel will find that the update of it will replace the content of any existing cell,it will warn you.It is important feature.
So, does it mean that Excel will always warn, when it sees that pivot table contents should be refreshed?
EDIT
It seems like my problem is similar to this one. However, I'm not using VB macros, I'm building my reports with some other programming language (which programmatically unzips xlsx file and deals with all those xml files inside).
EDIT
Well, I tried both Application.AlertBeforeOverwriting = False and Application.DisplayAlerts = False, but none of them works.
I haven't been able to reproduce the problem, so these are more suggestions than answers.
I think the commands you are trying are occurring too late - Excel needs to know "not to alert before overwriting" before it tries to refresh. If it refreshes on open, then you set the property, you have the wrong sequence of events.
Try:
Do NOT put refreshOnLoad="1" in your file.
Add the VBA routine Workbook_Open() to the workbook.
In the VBA routine, set the property Application.AlertBeforeOverwriting = False, then invoke the method PivotTable.Refresh.
This should resolve any "sequence of events" problems.
I am trying to develop a manner in VBA to track changes in a document without having to hide the contents in an extra sheet within a workbook.
I understand that if you change the extension of an Excel file to ".zip", you can access the Excel document as components sorted into directories. Is there a way to save and write to a text file within one of these directories so that I can access it every time the document is opened, without having to have the user drag a log file along with the Excel document?
Some facts:
When Excel opens the file, the file is blocked by Excel. There is no possibility to write to that file within VBA
You can store additional data into that file externally or after the Excel workbook has been closed
You would need to have code externally from the workbook to accomplish writing to that file after it has been closed. You may want to use VSTO or an oldschool Excel Addin.
you have to ensure that Excel will not destroy your changes when restructuring or repairing the file.
In the first run, your idea sounds very natural, to not use sheets from a programmer's point of view. You only have full control on Excel files when
you use external libraries (e.g. Spreadsheet Gear) or
you remote control Excel via automation.
you use openxml SDK for Excel
you use VBA
You could insert additonal information and take care that this information is not skipped by Excel.
When you want to do the tracking this way, I would suggest you to use an Excel Addin. There is actually no need for installation when using this kind of Addin. Attach to open workbook and close workbook events and ensure that all changes are written to the Excel Workbook after it has been closed. Certainly you would have to attach to all kind of other events to track all changes to the workbook. You may need to have in mind that there can be more than one workbook opened at a time.
Actually there are alternatives.
write your logging code in VBA or whatever fits
abstract away how your persist the code (e.g. use a data provider)
think about these two alternatives to store logging data:
You can save logging data in cells of excel. When using a "newer" version of excel, you have a limit of 1 million rows. You may want to implement a rolling mechanism that ensures that you never go over the border of 1 million records. (you may be dont want to track a million changes)
You can use the document properties to store you information as xml.
Last but not least, the most obvious: Why not using Excel's functionality of tracking changes? Understand track changes in Excel 2013
We have an Excel workbook which is similar to an Error Codes database. Unfortunately the application is written in such a way similar to IF (ExceptionCode != AnyPreviousExceptionCode) THEN (Make New Exception Code) which gives the messy problem of new, never before seen exception codes appearing on our monitoring software and requiring a team of analysts to investigate. The point being that this Excel workbook of Error Codes changes alot day to day, especially if a big release comes out.
The problem I have is that there is a team who needs to have this workbook open as they need to consult what error code is what, but there is also one person who needs to update this workbook. Excel of course gives full rights to whoever opens the workbook first and everyone else has to wait, however we have a global team so it's not a simple matter of going over to someone and telling them "please can you share the workbook to me".
Is it possible in Excel to set some users as read-only and other users as write access and have this reflect on the GUI so Excel doesn't make the write access user wait for the read-only user to close the workbook?
In Win7 for Excel 2003, 2007 & 2010 there is a dropdown arrow on the right side of the open button in the open dialog. If you click that you get an option to open the file as Read-Only. Can the non editing users open it like this?
Shift+Right Click on an excel file also gives the option to open as read only.
Sorry man, did not see your question a month ago :)
I am using Excel 2010 and am having difficulty with one old workbook created in Excel 2003. Lots of symptoms to report!
No other workbooks are giving me this problem. This problem file usually causes "MS Excel - (workbook name.xls) [Compatibility Mode] (Not responding) and a blank screen apart from the task bar and this Excel message on a single line across the top of the screen. Waiting doesn't solve the problem. If I close Excel and choose the "Close program" option, it sometimes shows me the file as I remember it for a couple of seconds, then the program closes. Re-opening the file just gives the same behaviour again. During the first few seconds of loading, I can see the message "Contacting server for information" at the bottom of the Excel screen.
In Task Manager I can find EXCEL.EXE *32 running. I'm using Windows 7 Pro 64 bit.
This is a file I use regularly in projects as a specialised calculator, and so I re-copy it each time and save it to save the calculation records in the project file. I've found that versions of the workbook created even several years ago and have given no trouble until now all suffer this problem, so it looks like a problem with Excel 2010. This is the first time I've tried to open these files since migrating from a Win XP computer running Excel 2003.
Please can anyone help me to open the file and to resolve the problem?
Thanks
There might be a calculation or a marcro activated on start up that messes things up.
Try the following:
Open the Excel application, with a blank workbook. Set calculation to manual. Now look up your Macro settings and set these to "disable with notifications".
With these things set, open your misbehaving workbook again and see what happens now. Dont let the macros (if any) start yet! Open the VBA Editor window and check for a script in Workbook called Workbook_Open. If that is present check its content or put a break in and debug it.
Let us know what you find, if any.
UPDATE:
It sounds like there is a database link to an external source that is trying to refresh on startup but isnt working correctly (anymore). I now remember likewise behaviour when I had an Excel workbook with tons of SQL queries in it that (in case of showing a complete table or view by applying SELECT * FROM ...) could overlap other data and that would create autoshutdowns for me. Change the option in the Trust Center for External Content to Disable when you open this workbook and let us know!
I have a client with the same issue. The problem was resolved by removing all the logo's (Images) from the sheet. It appears that the logo contains a link to some web site. I copied the logo into paint and copied it back.
Problem Solved!
It appears that an object placed in the sheet can have its own links embedded in it???
I hope this helps!