Programmatic Access To Visual Basic Project Is Not Trusted - vba

I have two scheduled tasks on my computer. They both open Excel files and run a macro & are pretty similar in what they do. They both work on my computer. However I moved the scheduled tasks onto a colleague's computer. One worked the other didn't.
The one that didn't work opened Excel but had an error saying:
"programmatic access to visual basic project is not trusted".
Like I say, both Excel files are very similar. The one that didn't work does reference two additional projects the other one does not. They are,
Microsoft Visual Basic for Applications Extensibility 5.3
Microsoft Windows Common Controls-2.6.0 (SP6)
I have never come across this error before.

File -> Options -> Trust Center -> Trust Center Setttings -> Macro Settings -> Trust Access to the VBA Project object model.
This is usually needed if you are referencing Extensibility library.

Mac Version - In the past there was no setting for this on the Mac version. You did get always a dialog saying the thing.
But now, at least with version 16.30, not sure how long ago, the Mac Users have the same setting available.
BTW, it is under security, not under trust.
HTH

Its very easy to do this in Python using the pywin32 module by Mark Hammond.
What the above post by #user2140173 does actually is to change some registry values. This can be programmatically accomplished by the pywin32 module as follows:
import win32api
import win32con
key = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER,
"Software\\Microsoft\\Office\\16.0\\Excel"
+ "\\Security", 0, win32con.KEY_ALL_ACCESS)
win32api.RegSetValueEx(key, "AccessVBOM", 0, win32con.REG_DWORD, 1)
Ref:
http://docs.activestate.com/activepython/2.4/pywin32/win32api__RegSetValueEx_meth.html
http://docs.activestate.com/activepython/2.4/pywin32/win32api__RegOpenKeyEx_meth.html

Related

Cannot see local class variables while debugging DLL in Visual Studio..?

I'm trying to debug a DLL that I've written in VB.Net. When the external program starts, it loads the DLL and everything runs fine...but I cannot see the class variables in the Locals pane. They show up blank as shown below.
Also, some lines of code generate the error "There is no source code available for the current location", but I think I understand why. Whenever it tries to step into class members of any of the Microsoft DLLs, it would of course have no information for those. But any lines which deal only in code that I've written, it works fine.
This is a COM DLL AddIn for Microsoft Access 2007, but I'm assuming the issue is roughly the same regardless of the type of DLL. The Shared COM Addin Wizard was used to get started, and then customization proceeded from there with satisfactory results...except for the invisible variables in the Locals window.
I'm new to writing & debugging a DLL like this; until now I've only done EXE files. I've researched MSDN, Google, and Stack Overflow, and here are the details that are asked about on other threads...
Visual Studio 2008, .Net 3.0, and Access 2007
Project Properties > Debug > External Program points to MSAccess.exe.
Project configuration is set for Debug.
Optimizations = off.
Generate debug info = Full.
The PDB file is present in the \bin\ folder with the DLL.
Breakpoints are working.
Debug.Print messages are working.
I dug through the registry and found all references to the project, DLL, and its custom UserControl (required since the project creates a CustomTaskPane, and all path paths point to \bin\ folder.
What am I doing wrong?
What am I doing right?
What can I improve?
Ok, answering part of my own question. I think I fixed the error message "There is no source code available for the current location". In the project properties "Enable unmanaged code debugging" was enabled.
With that option disabled, I can now step through the code without error, even if it hits objects for which I have no code. The debugger is acting a little differently too, but I haven't yet pinned it down. I did read up on the differences between managed & unmanaged code, and debugging them in mixed combinations, but while I understand in principle, I don't yet understand in practice.
My local variables are still blank, though.
Alright, after working on this for days in between other projects, I have an answer...of sorts. I think the solution and/or projects had become corrupt. I'll pass along what I can in the hope it may help others.
Yesterday I had a marathon session of "click everything", in the project settings and Options > Debugging, but nothign helped. At some point I stopped fiddling with the debug settings and continued working on the code until I was tired and went home.
This morning with a fresh mind I tried again, and discovered the private class variables were now all visible. And I don't know why. Also, there was a new problem: the Just-In-Time debugger prompt kept popping up, even thought it wasn't enabled in the settings:
Also, the play/stop/step toolbar buttons would become disabled when they shouldn't be, yet the menu selections for the same items functioned normally.
I double-checked all settings again. I played with everything and could NOT get the local class variables to become invisible again, and could not get the JIT dialog to go away.
So I...
Made a copy of the solution folder.
Cleaned the solution.
Rebuilt the solution, including the Setup project.
Uninstalled the Setup project from Windows via Solution Explorer.
Cleaned the solution again.
Deleted the SUO file.
Deleted everything in \bin\ and \debug.
Rebuilt the solution, including the Setup project.
And still the problems persisted.
After the JIT prompt, I clicked Continue (F5), then closed MSAccess. Aafter execution stopped, some IDE panes (such as Explorer, Locals, etc) disappeared, and some flew around to random locations on the screen. It was then I decided something might be corrupt, and started making plans to uninstall/reinstall all of Visual Studio 2008 from scratch, and possibly even a new solution from scratch.
So before reinstalling, I tried creating a new solution from scratch, and found everything worked perfectly, even with all settings as they were from the original solution.
So in the original solution I...
Exported the settings from Tools > Import and Export Settings.
Reset all settings.
Imported the settings I just saved.
At the moment the import dialog closed, I received the error message: "An unexpected error has occurred".
When restarting the VS IDE, I received a dialog that said "Visual Studio is configuring the environment for first time use". That didn't sound good.
Tried importing the settings again, same error.
Rebooted, tried importing again, same error.
Closed the Solution file, tried importing the settings again without any solution open, and it worked....or seemed to.
Then opened the Solution...and same problems were back.
Exported the settings from the new Solution.
Imported those settings into the original solution...and it's fixed..?
There was no import error, and the project started working correctly..!!
The local class variables were visible, and the JIT prompt was gone..!!
So...I guess something was bunged up in the Solution, one of the Projects, the IDE settings, or...something. I hope this helps someone else.

VBA /Visual basic projects/macros issues while compiling

I have so many problems with any of the VBA/VB projects, that I am by now not sure which category these problems falls in. Some of the issues listed below may or may not be interrelated. But any thing that is related to visual basic project is causing me so many problems since 1 year.
I have researched so many time but have not got a solution till date :(.
But this time I could not stand it any more and therefore I am here to post it.
I had Microsoft visual basic 6.0 installed in my system last year. I was able to create some small windows based forms->compile and run as well. However, when I have a project from external resource for supporting VB applications, none of the project were compiling and running through IDE.
So i researched a lot and found the below issues:
Missing references/missing dlls. added references but no use
Tried help got this error: msdn collection does not exist please reinstall msdn
Tried Compiling - got error:
Compile error: cannot find project project or library
Tried adding components : failed by getting error Dlls are not registered.
Error in project loading, found the below error
Then I tried registering the MSCOMCTL.OCX file through regsrv.exe but it gave admin related errors as below
call toDllRegisterServer failed with error code 0x800280c
Even though I have all admin rights and I am logged in as admin for command prompt.
I also had copied the files from syswow64 to system32 or vice versa whichever way it did not work
Somewhere I had googled that we need to unblock the files to register , but these files were not blocked.
Tired, I just left the problem just like that due to other prioritised work.
But again today my colleague gave me an excel sheet which had macros written in it.
These macros do not run, instead it redirects me to Visual Basic for application IDE where the first window i get is Compile error followed by automation error
Again I thought of researching more on to it, and finally found from SO only that we should be registering MSCOMCTL.OCX.
But no matter what I do, I am unable to register any dlls.
Can any one tell me what is causing so much of compile issues , the solution and why I am not able to register any dlls or files?
And by the way, my system is window 7 64 bit and I seem to be only one in the workplace having this problem.
This issue was present even before any updates. The same profile with the same updates are running in my colleague's system. Even though there were no patch updates etc.
Try this:
Open a Command Prompt:
Open START menu, in Search box enter: cmd.exe, a link will shows, BUT doesn't press Enter key, instead RIGHT-CLICK on the link to open context menu, then choose Run as administrator
A Prompt DOS (black) windows will open on C:\Windows\System32 folder.
If your OS is 32 bit then type the below commands:
regsvr32 mscomctl.ocx press Enter
regtlib msdatsrc.tlb press Enter
If your OS is 64 bit, need to navigate to C:\Windows\SysWOW64 folder: Type the command:
CD C:\Windows\SysWOW64
then press Enter key to confirm.
Type the below commands:
regsvr32 mscomctl.ocx press Enter
regtlib msdatsrc.tlb press Enter
Now should working
HTH

Not able to type anything in Xamarin Source code editor

I have installed Xamarin Studio V 5.7 on Mac OSx 10.10.1.
I created a project and tried to edit a source file in the Xamarin Source code editor, nothing gets typed in any of the files from the project.
I re-installed Xamarin studio, restarted mac, nothing worked.
If anyone has faced the problem and has a solution, please let me know.
Thanks in advance.
There is a valid subversion repository towards the root of the file system and XS sees the project as being part of the repository, since the system is based on directory trees. There are a few possible solutions I can think of on the spot:
Remove the .svn directory if it's not intended to be there.
Move the project into another directory that's not in the scope of the .svn directory.
If you aren't going to use Subversion anyway, you can disable the AddIn through the AddIn manager.
There are safety checks in XS in case of invalid subversion repository directories, but this is a case where you can't safely decide whether the solution belongs there or not.
I'll take a look at how I can improve this so that the Editor isn't locked because of this error.
I was able to remedy the issue via disabling the integrated source control for the time being.

Unable to debug ArcGIS 10.2 add-in on ArcMap with “No GUI components found in this Add-In”

I am working on an ArcGIS add-in (a very simple toolbar with a few buttons) with VB.Net and ArcObjects SDK in Visual Studio 2010. The solution was built successfully and the debug settings were configured.
When I hit Debug, ArcMap application was opened. I couldn't find the toolbar docked anywhere on the ArcMap toolbar. I went to "Customize" -> "Add-in Manager" and the add-in being debugged was not there. Then I tried "Add From File...", located the "esriaddin" file and clicked "Install Add-in". It populated a message box saying "No GUI components found in this Add-In."
I made some Google searches but haven't got any luck to reach a solution yet.
What was I missing? Has anyone come across the same issue and any direction?
Thanks in advance!
Try clicking build first, then open the arcmap separately and check the add-in manager inside of arcmap to see if it got added to the application. If so, you should be able to find it and turn the toolbar on.
I'm not sure about .Net, but I debugged this issue for the Java SDK. You have to make sure you are using the correct versions for compiling. In java, it was an old archive version of jdk1.6 32 bit.
Then I was referencing something wrong inside the xml document. I had changed the name of my JAR file (taken from project name by the ArcObjects SDK). In the xml document it was still pointing towards the old name.
This may not help you, but if anyone else searches this error and is using tje Java SDK, hopefully it will help.
I struggled with this same issue with a 10.0 add in. We had a 10.1 update that worked with 10.1 but trying to install it to 10.2.2 gave me that exact error. So much for upward compatible! I then tried to build 10.2.2 code and kept having this error. Others mentioned needing to build to x86 so I did that although the 10.1 was on Win7-64 and ran with AnyCPU....
I believe the final key for me was in the config file. I had set version to 10.2.2 As soon as I changed that to 10.2, the darn add-in installed just fine. Nice waste of a day for an extra '.2'

Sharepoint solution not showing up in Site > Features

I do not know alot about sharepoint and I am having trouble installing a sharepoint solution.
I am trying to install this package called "Workflow Actions for SharePoint Designer 2010" - It installs fine and I can see it inside "Central Administration -> Web applications -> Manage Features" and it is "ACTIVATED", But when I go to "Manage Features" of my site, I cannot see it there.
What Am I doing wrong here? If i go and select the "Feature.xml" file it says
Scope="WebApplication"
How do I fix this problem?
EDIT: I actually need to make a call to a webservice when a workflow starts, and this package seems to offer that. If there is any other package that I can use to call webservice that will also solve my problem. Thanks!
http://ilovesharepoint.codeplex.com/wikipage?title=Install%20Workflow%20Actions%20for%20SharePoint%20Designer%202010&referringTitle=Workflow%20Actions%20for%20SharePoint%20Designer%202010
If you want a feature to be installed at your Site Scope then you can change the scope to Site from the feature properties in the feature you have created.
Well after going through a dozen different things I was able to install it myself. Looks like the documentation on the link i gave out above does not work, or atleast it didnt work for me.
I had to force enable it by running powershell and running the command.
enable-spfeature -Identity {GUID} -url {URL}
To find the GUID - goto 14/Templates/ILSPSPDActions and edit the Feature.XML file. It has a GUID in it.
Although after running the above command, the option still didn't appear inside Site Collections -> Site Features -- But it did the trick. Once executed successfully, restart the Sharepoint Designer 2010 and its workflow actions menu will have additional actions in it.
Hope this helps someone.