E_ACCESSDENIED "General Access denied error" /CreateObject("Vbscript") blocked under office 365 VBA environment [duplicate] - vba

This question already has answers here:
MS Access VBA Error: Run time error '70' Permission Denied
(3 answers)
Closed 1 year ago.
I have recently encountered an issue running code within Access 2016 and for office 365. Our COM component that we authored stopped working with the newer versions of office. I was able to attach the debugger and confirmed that trying to create an instance of VBScript INSIDE of VBA (our COM object uses Vbscript internally to execute code on our projects called via Access VBA ) returns E_ACCESSDENIED when CoCreateInstance is called inside of our COM object. Previous versions of Office as late as 2013 this worked just fine.
Also if you just run:
Dim tst As Object
Set tst = CreateObject("VBScript")
If Not (tst Is Nothing) Then
MsgBox "good"
Else
MsgBox "Bad"
End IF
In Excel or Access VBA on anything greater than 2013 I get:
"Run-time error '70': Permission denied" on the CreateObject("VBScript") line
VBScript CreateObject error message
This code executed just fine for me under office 2013 as well.
I have tried the following:
Setting ActiveX settings to enable all ( Under "Tust Center" )
Enable all Macros ( Under "Tust Center" )
Disabled "sandbox" at all times using the instructions listed here:
https://support.microsoft.com/en-us/office/turn-sandbox-mode-on-or-off-to-disable-macros-8cc7bad8-38c2-4a7a-a604-43e9a7bbc4fb
Does anyone know if there is a setting of some sort I can change in office to allow a vbscript instance to be instantiated from within office 365 VBA environment?
I have searched for a similar issue on the web and so far have found nothing useful.

So Thanks to sous2817 I was able to find actually what it was that I needed. While it may not be the most secure approach in all cases it should work for me.
I also found these 2 links that I used once I was pointed in the right direction:
https://support.microsoft.com/en-us/topic/security-settings-for-com-objects-in-office-b08a031c-0ab8-3796-b8ec-a89f9dbb443d
https://learn.microsoft.com/en-us/office365/troubleshoot/updates/control-block-ole-com
Basically I had to make an exception to prevent MS Office from blocking VBScript.

Related

How to get the current running office instance version number using VBA?

I am developing Microsoft Office Add-in, I have to read the registry values of the current instance of the office in which my add-in will run.
Is there any way I can get the current office version number of add-in instance?
I have searched and found this solution. But it's is not working.
Thanks if anyone from you can help.

Access 2010 report ignores filter placed on it

I have run into an error with an Access Database created in MS-Access 2003. It's known the Calendar Control was deprecated in Access 2010 but unfortunately we need to keep using it. As a temp fix (until we can change to the date picker) we restored the MSCAL.OCX file on all 2010 users.
The issue:
We have a form to print schedules from a date range (using the calendar control). There is some VBA code to check to dates etc to make sure the range is accurate etc.
Everything works fine in 2003 but in 2010 the dates get selected fine on the form, is passed to the report (a print preview) fine as it displays in the footer BUT the query ignores the date range and prints ALL records (not just the records in the date range).
Is there any way I can step into Print Preview button when clicked to see what's being passed?
Any other ideas?
The issue with the filter not being applied to the report is a known Microsoft issue with certain set ups of Windows 7 and Access 2010. The hotfix found here: http://support.microsoft.com/kb/2596496 solved my problem.
I run Windows 7 64 bit and Office 2010 32 bit, when downloading the hotfix I selected the "x86" platform as that's the 32 bit. If you are using Office 2010 64 bit you should download the "x64" platform.
To find out your office version, open any office product, click File Tab, click Help and it will be on the right under "About Microsoft ".
The only way you can really do that is if your report/query is running some VBA code and put a Stop on the the VBA.
If your query is referencing the fields directly (IMNSHO a bad practice, but I'll work with what we've got) you could change them so they instead reference a VBA function that returns the results of those fields instead. Then you know what it is getting for sure.
There is one more trick that surely worked out for me as a solution, before I came across the accepted answer about hotfix on this thread. Also, because, the hotfix link leads to a valid thread, but there are not downloadable files.
The workaround:
Make a copy of the report file. Use that name in VBA under DoCmd call. Strange how it works, though. Such is the nature of bugs, I guess.

Cannot run excel function from MS Access

We are migrating an MS Access 2003 app from Office 2003 to Office 2010 (and WinXP => Win7) and have run into a problem trying to run the Excel Yield function from MS Access. The current code to do this (which works on XP / Office 2003) looks like this:
Dim objExcel As Excel.Application
Set objExcel = New Excel.Application
objExcel.RegisterXLL objExcel.Application.LibraryPath & "\ANALYSIS\ANALYS32.XLL"
dblYield = objExcel.Run("Yield", dteTDate, rstSec.Fields(2), dblRate / 100, dblPricePaid, rstSec.Fields(7), rstSec.Fields(4), rstSec.Fields(6))
The code errors on the final line and gives the following error:
Run-time error '1004':
Cannot run the macro 'Yield'. The macro may not be available in this workbook or all macros may be disabled.
I've tried a few things, including specifically adding and registering the Analysis Toolpack using the following code:
objExcel.RegisterXLL "C:\Program Files (x86)\Microsoft Office\Office14\Library\Analysis\ATPVBAEN.XLA"
But I get the same error.
I'm thinking at the moment that the problem may be down to maybe needing to create a macro enabled workbook, or perhaps it's some Win7 / Office 2010 security setting that I am unfamiliar with.
The only potential solution I can come up with at the moment is to create a COM interop .net assembly that wraps an Excel instance exposing the Yield function. However I'd prefer a different solution because to go the COM interop route I'd have to get admin rights, then to deploy I'd have to register the dll on the end users machine, in addition I'd most probably run into the same error in .net as in MS Access.
Finally there is a .net project to recreate a number of the Excel financial functions in an F# assembly. Unfortunately the Yield function is not one of the re-implemented functions.
I'd very much appreciate any advice on this,
Cheers,
Jamie
If anyone has the same problem, the way I solved (worked around) it was to use an external workbook in which I had the yield formula in a cell, referencing a bunch of cells containing the yield parameters. I then replace the parameters via my Access vba function, force the worksheet to recalculate the formula and return it to my Access database.

TF249051: No URL can be found that corresponds to the following server name

So am trying to open work items in Excel on my machine (TFS 2010 and Excel 2007) and I received original error from Excel
TF80070: Team Foundation encountered an error while performing the operation.
I found instructions on how to turn on diagnostics to find the underlying cause which is the error in the title
TF249051: No URL can be found that corresponds to the following server name
I cannot find anywhere in Excel that I can tweak the settings. How can I resolve this issue?
So the solution I found (after disabling and re-enabling the addin inside Excel and also removing the addin from inside Excel and re-adding it) was to go to the Team menu in Excel and click New List. It prompted me to connect to my collection which I did and then opened up a query (My Tasks). I guess somehow it didn't know exactly what to connect to although the complete error message I got from the diagnostic trace included the correct tfs server name and default collection name.

Office 2007/2003 VSTO Shared Add-In Design Query

I am designing a shared add-in using VB.Net 2008 and VSTO that has to fire up when any MS Office App is started. It has to work for both 2002, 2003 and 2007 applications. I have managed to put together a working add-in that pops up a test message stating the version of Office and the Application name and tested this across all the apps ok.
The next part of the solution is to code the application specific code that needs to run for document auditing and corporate protective marking as well as, for example; in Excel checking that all the Add-Ins are linked to the Network Add-Ins folder.
My approach from now was going to be to late bind against the application object and set one of my typed (e.g. Excel) application object references which exist in the code to this object.
I'm still relativly new to VSTO so if I am doing something odd please can you let me know! :)
Ta.
I have completed this project and did it the way I specified using late bindig. It works lieka dream for all office apps both XP and 2007. :) I feel like I am announcing this to myself though as I didn't recieve a single answer or comment. Maybe you should have sexed up the title a bit Mas. Yeah maybe I should.