In Excel, I’m having my cursor/selection on a specific cell. Up until a recent Office update, the behavior upon inserting an Office.js-powered “content add-in” was like this:
The add-in is being inserted
The container of the web control is focused (you get the resize handles and Excel reveals the Drawing Tools menu) and the focus on the sheet is lost
getSelectedRange() right now would not yield any results but an error
You need to make at least one click into the web control’s area to de-focus the container and focus both the web control and re-focus the cursor/selection on the sheet
getSelectedRange() works now
After a recent update, I’m using Excel for Office 365 Version 16.0.11328.20362 now. And the behavior changed to this:
The add-in is being inserted — unchanged
The container of the web control is focused and the focus on the sheet is lost — unchanged
getSelectedRange() right now would not yield any results but an error — unchanged
Clicks on the web control don’t change the focus anymore, the container keeps being focused!
While the old behavior was already cumbersome as interaction between the add-in and the sheet was not possible directly after add-in insertion (only after at least one click), now not even the workaround of making that single click in the add-in is working anymore.
My original requirement was to read data from the sheet that has been selected just prior to inserting the add-in (just like it works with the native Excel charts). That’s why I had to come up with this one-click workaround in the first place.
What is now the best (if any) way to work with the workbook/sheet right after inserting the add-in with as few quirks as possible?
Related
I have an Excel spreadsheet with VBA programming, form activex controls, form controls. The spreadsheet has worked normally, until last week. I think the problem started when the automatic installation of windows uptade took place, however it might be only coincidence, since I am not positive if this is the cause. Now, the spreadsheet opens and immediately a small window appears that indicates :
“Visual Basic for Applications - Permisson Denied to use object (OK,
Help)”. Selecting help, minimum information and it is irrelevant.
Selecting OK, another window pops out “Visual Basic for Applications -
Unexpected error 419 (OK, Help)”
I cannot even save the sheet to another name. The VBA code cannot run. If I open any new spreadsheet, Excel functions normally, also with its VBA. Just before having this problem, every time that I opened the spreadsheet a window appeared, indicating that Excel blocked the functionalities of the ActiveX controls and asking that if I would allow the use of ActiveX. Today, I enabled all macros and also all activex controls. My previous backups of this spreadsheet have also the same problem. None works. I went to VBA Edit-->References and compared the Libraries I had and the Libraries that are there on the spreadsheet. It seems that no library is missing. How to solve that?
The permissions have changed on your workstation and/or network. Specifically, the folders that hold the DLL files that contain the objects referenced in the VBA. As an example (and I don't know if this is exactly the case, but an illustration), if your code is referencing the Microsoft Scripting Runtime (many VBA projects do), your code needs permissions to access C:\Windows\SysWOW64\scrrun.dll. (I found this by calling up the VBA editor, selecting Tools-->References, then selecting Microsoft Scripting Runtime and reading the bottom of the dialog window for the location.)
This is the location of the DLL on my workstation. Yours might be different or it might have moved during a systems update or the permissions to access that folder may have changed. You'll have to check the locations of all the references in your VBA project to determine this. Sometimes the libraries referenced are located on network drives, which can complicate matters if the network permissions change.
I decided to try to export all the forms (*.frm; *.frx). Everything went fine until I came across to a specific form that had a shockwaveflash object. At this point the message "Permission denied to use object". Bingo!
I then tracked the location on my workstation of such shockwave object reference and applied full administrator control. However, I still could not use shockwave objects. I then uninstalled flash and downloaded the lates shockwaveflash plugin from Adobe. When I open Excel->Developer->Insert->ActiveX Controls->More Controls -> ShockwaveFlashObject and then insert the object in a sheet, the message: "MS Excel - Cannot insert object" appears. I have manually deleted the "*.exd” from C:\Users\[User ID]\AppData\Local\Temp\Excel8.0. Also deleted from C:\Users\[User ID]\AppData\Local\Temp\VBE\, but the problem was still there: "Microsoft Excel - Cannot insert object".
To solve the issue I finally accessed the VBA editor and deleted the userform that had the ShockwaveFlashObject in it. All went back to normal afterwards.
My Problem: Treeview Control 6.0 becomes unresponsive in Excel 2013 64 Bit (Compile Error: Method or Data Member Not Found). I am able to delete the control, insert a new Treeview and it initializes fine (loads Imagelist, allows user configuration of nodes, etc.); however, once I save/close/reopen it becomes unresponsive again. This Excel tool allows users to configure a dashboard using Treeview and it worked fine (still works fine) in Excel 2007. I can include the code to initialize the Treeview control, but it is not a code issue as it works perfectly in Excel 2007.
Attempted Solutions: I have read through many forums and have tried numerous solutions to fix, but none have fixed the issue...
Running a batch file (as Admin) to unregister/re-register MSCOMCTL.OCX in the correct location
Deleting all .exd files from my hard drive
Removing/adding Common Controls reference in VBA editor
Deleting/Recreating the Treeview numerous times
Repeating above solutions in every possible order
The strangest part to me is that I can re-create the Treeview (insert, set properties), run code to initialize, and completely configure the Treeview with no issues... it only becomes unresponsive after saving/closing/re-opening. Again, the opening/closing routines worked fine in Excel 2007 so I don't think it is a code issue.
Any help would be greatly appreciated... I need Treeview to work as it stores all of the user dashboard info (TV terminals, files to open/close, etc.).
I encountered the same problem with EXCEL 2016, 32 bit version. EXCEL does not recognize the embedded TREEVIEW control after saving and reopening the file. (Sometimes it would work on the first save and reopen, but fail on the second.) This problem did not occur with EXCEL 2010 and earlier, same spreadsheet. Like you, I can embed a new TREEVIEW control, name with the name the macro populating uses, i.e., the name originally given to the unresponsive TREEVIEW control. I did not have to delete the unresponsive control like you did because EXCEL did not recognize it. You can check this by going to Develop tab and activating the properties view.
Curiously, I found a couple of workarounds this bug in EXCEL:
When I saved the file while in Developer mode, it opened OK and the TREEVIEW control worked, but you have to run a macro to populate. So far it works, but who knows....
When I embedded the TREEVIEW control in a Form, rather than directly in the spreadsheet, it saved and reopened OK, at least so far. No need to be in Developer mode or rerun the populating macro.
Good luck, maybe one of these will work for you.
I have an uncommon issue. I have an Excel file with macros. On all computers it was installed Office 2010 and everything worked fine, but a few days ago every computer was upgraded to Office 2013.
In code, at some point I enable or disable some buttons based on some criterias.
ThisWorkbook.Worksheets("Lab Orders").OLEObjects("CommandButton1").Enabled = False
On some computers this works fine , but on other computers this button is shown as enabled, and if the user clicks the button nothing happens, not even the animation where the the button is pressed, so it cannot execute the code behind. It's like an image. Any leads, or reasons why this is happening only on certain computers ?
I have this problem after the Office got upgraded. PS. All computers are in the same domain.
LATER EDIT
I changed the code line
ThisWorkbook.Worksheets("Lab Orders").CommandButton1.Enabled = True
and now I get this error: 438 at this row (I debbuged the file on a computer where this file does not work)
I suspect it's the issue with the latest Office updates - see if this fixes it: http://excelmatters.com/2014/12/10/office-update-breaks-activex-controls/
On all computers where you have the problem, check the box "Trust access to the VBA project object model" located in Options/Trust Center/Macro Settings
(Note that this will only apply to Excel, and if you are having the same problems on other MS Office softwares, you should do the same on them as well)
If that's still not working, read and apply all the checks on this page : https://support.office.com/en-gb/article/Enable-or-disable-macros-in-Office-files-12b036fd-d140-4e74-b45e-16fed1a7e5c6
Did not fit as a comment, so:
If I understand you correctly, some computers show the button enabled, while in fact it is disabled, right?
In this case it's normal no button press animation "visibly happens" as Windows knows the button was programmatically disabled.
The same thing happens if you hook a window (which has buttons on it) and send any button a WM to show itself as if it was enabled (while in fact it is not).
The reason it seems enabled on some computers may vary, most probably it's video card and/or driver 'issue', or some "strange alignment" (that particular OS with that particular graphics card & driver and DirectX, as well as those 'special' OLE settings, etc).In both cases, the screen area don't get "refreshed" (invalidated) after the button was disabled - so it seems enabled and gets "repainted" only when there was some user interaction around it. "Lazy redraw", so to speak :)
What one can do is, if it happens to be a serious issue, to find a way on one of these computers to get the button visibly disabled with some 'workaround' (e.g. changing button text after it was disabled -maybe even to exactly the same text-, or move it 1 pixel away and back, call InvalidateRect on it, etc), and apply that solution to your Excel macro.
UPDATE after reading asker's comment:
Oh I see. This could happen if the buttons are in a control array. The issue in this case, however should be present on all computers... Strange.
Anyway. Try to test the buttons' Index property to see if they are part of a control array, just to be sure. If yes:
a) remove them from the array and create buttons "independent" from each other
b) create a bool array and store there enabled/disabled status and write a function that updates buttons' text color property & handles button click event ignore/accept
I am using Excel 2010. I have already created and tested 2 complex forms frmA and frmB. They run and then save data to the workbook when user hits Apply or OK. Now my user wants frmA to be able to call frmB, do some work, then return to frmA. I thought it might look professional if they could be on a MultiPage, but I don’t want to rebuild and retest these forms.
Is there anyway I can create a 2-tab MultiPage form and then make frmA appear on the first tab, frmB appear on the second? Then I can simply handle the communication between the two instead of recoding.
Or maybe I can just paste all the objects and code from each form onto the tabs and do some object renaming. The retesting will be extensive, though.
If not, I will have to do frmA.show, (user clicks Open frmB button), frmA.Hide, frmB.Initialize, frmB.Show, (do some work, hit Apply/OK/Cancel), (update spreadsheet with changes), frmB.Hide/Unload, (frmA.Initialize due to changes), frmA.Show. I have not gotten this to work properly yet – frmA disappears and doesn’t come back, but I will work on it if the MultiPage is not possible.
Maybe you can save me time by pointing me in the right direction.
I am accepting #guitarthrower 's answer:
To answer your question, no you cannot embed one userform in another using Excel VBA. – guitarthrower
We would like to export a view of a custom SharePoint list to Excel on a repeatable basis, and with some minor formatting.
I have made a .iqy file by using Actions/Export to Spreadsheet from the view menu, and then uploaded this .iqy file back into SharePoint. When users click on it, it does bring up the data in Excel - but without the headings repeated each page, with the columns spilling onto a second page (width-wise), etc.
The .iqy file seems to be a plain text file which can be opened in Notepad so perhaps there is a way of passing parameters to Excel through this which would do the trick? Does someone know?
Alternatively, I also saved one of the resultant spreadsheets from opening the .iqy file, applied some formatting to it, and then uploaded that back into SharePoint. I set it to refresh the data connection on opening and I think this is working ok except there are two frustrations.
Firstly, by default, Excel says it has blocked data connections and I need to manually enable them. Is there a way to prevent this short of editing the trust centre settings on each computer that will open this spreadsheet?
Secondly, when I click on the spreadsheet in SharePoint we are asked if we wish to open the document for editing or read only. Ideally, I'd like to just give the user the opportunity to open or save the document (and certainly not to save it back on to the server, as I expect Edit would do.)
Does anyone have any sage advice for me that would make either the first attempt (.iqy file) or the second attempt (formatted spreadsheet) work successfully? Or maybe you have other, better ideas?
Thank you,
Regards,
David W
An Excel Web Query (iqy) is just not going to work. Its only purpose is to define a "web query" for Excel to open.
First frustration, I am not positive, but digitally signing the workbook may avoid the blocked data connection prompt. Also, if I remember correctly, there is a Global Policy setting for this, so if you are part of a domain, you can have this setting changed when the user logs into the domain.
Second frustration. Not much you can do here.
Suggestions, all kinds. We would need to understand your requirements and constraints. But, I suggest you dynamically create the workbook using XMLSS. You have full control over formatting, layout, and nearly everything else, without the need to have Excel installed on the server. The served workbook must then be saved locally and cannot be saved back to server.
See XML Spreadsheet Reference at
http://msdn.microsoft.com/en-us/library/aa140066(office.10).aspx
Here is a search for "visual basic asp xml workbooks site:microsoft.com",
http://www.bing.com/search?q=visual+basic+asp+xml+workbooks+site%3Amicrosoft.com. Search for ASP generates more results. Note it is easy to translate/migrate to ASP.NET so do not let the ASP throw you.
I recommend starting with Using Visual Basic and ASP with XML to Generate Excel 2003 Workbooks at http://msdn.microsoft.com/en-us/library/aa203722(office.11).aspx, especially near the end of the article because there is an example on creating a workbook and setting the page print orientation. Moreover, there is an example on how to create a template.