Can't use vba flex grid msflxgrd.ocx in ms-access - vba

I wish to use a flex grid in my access form. I downloaded and registered msflxgrd.ocx successfully. It now appears in the list of insertable ActiveX controls in forms design, so all seems OK. But when I select the control named "Microsoft FlexGrid Control, version 6.0", I get the following error:
Microsoft Office Access doesn't support this ActiveX control
What's happening here? I am using Access 2007 - do I need a different control and is the one I tried to use supported by Access 2003 only? Or is something else wrong?

OCX components can be disabled because they could be malicious if they are used in a browser.
To make this component work, you need to edit the registry:
HKLM\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\Compatibility Flags
Change Value from 1024 to ) for CLSID {6262D3A0-531B-11CF-91F6-C2863C385E30}, or the CLSID of your OCX Component.

I had the same problem, or what I believe is the same problem, with Access 97 and the TreeView control (which is actually from VB 5.0).
Even though I found and tried Vbcmpfix.exe, and it claimed to add the licenses I needed, it didn't. I also tried registering and unregistering and replacing the ocx. I tried this with the 64-bit cmd.exe and the 32-bit. No change at all.
MS VB5/6 licenses apparently all live in HKCR\Licenses.
I was able to solve this "You don't have the license required" error by exporting that branch from a working XP box and running that .reg in W7 64.
There's also a collection of vb6 license registry entries floating out there called VB6Controls.reg. It had what would appear to be the same values in it, and I tried it on a different box and it also worked right away.
I had to create an account just to share this solution. I found dozens of web pages with people unable to solve this, so perhaps this will help someone.

Related

Excel 2013 - ActiveX warning despite allowing all ActiveX in Trust Center

I have an issue I'm struggling with, and it bothers me to no end. However, I can't come up with a decent solution, so I'm turning to you folks for advice.
The problem is as follows:
I have a .xlsm file containing a few macros. The macros use Forms, and specifically they also use TreeView objects in them (through mscomctl.ocx). I have gone through the Trust Center, and set every setting to it's unsafest form (allow all ActiveX, allow all VBA, no 'safe mode' for web documents, etc etc...
I can open the file, but when I call the macro relying on forms, I get a warning message labeled 'Microsoft Forms', with the following error message:
This application is about to initialize ActiveX Controls that might be
unsafe. If you trust the source of this document, select Yes and the
control will be initialized using your document settings.
It both surprises me (I said to allow it all in the settings, didn't I?) and annoys me (well, not the first time, but me and my coworkers use it on a daily basis and it gets on my nerves).
Does anyone have a clue whatsoever as to:
1) Why this happens?
2) How I can avoid the message?
I'm open to both solutions on altering the Excel file, or settings I have to alter on local machines (<20 PC's).
Details:
Windows 8.1, running Excel 2013. The macro-code is 'safe', it's built by our company employees (myself included). Code is password-protected so can't be meddled with.
Try the below steps
1) Launch Excel
2) Click "File - Options"
3) Click "Trust Center"
4) Select "ActiveX Settings"
5) Modify "ActiveX Settings for all Office Applications" from the default ("Prompt me..." - see above) to "Disable all controls without notification"
We see same error in an Excel solution with a TreeView form-component on 64-bit Win7 and solution here is to re-register mscomctl.ocx
Bat-file code:
regsvr32 /U "C:\Windows\SysWOW64\MSCOMCTL.OCX"
regsvr32 /S "C:\Windows\SysWOW64\MSCOMCTL.OCX"
Regards

Visual Studio - Visual Basic - Protected Memory Error?

Currently I am using Visual Basic 2008 (.NET Framework 2.0) to create a program. However, when I add or select controls such as panels, group boxes, etc. I get error messages. For example, when I try to add a panel control I get the following message,
After clicking OK button, the panel control is added but the following happens to the panel control,
Yet I can still add other controls inside it. When I save and re-open the project, it shows the normal panel control. But when I select the panel control it does as shown in the second image again.
I tried this in Visual Basic 2008, 2010, 2012 and 2013. Same thing. I have full administrator access to the computer.
What is the reason for this and how to fix it?
I re-installed Windows and then Visual Studio 2008. The error did not occur after that. But when I updated the computer via Windows Update, the error came back.
Try creating a new project, then copy and paste code from the old project. You may or may not have to recreate the forms in the designer. Also, make sure you have System, System.Core, System.Drawing, and System.Windows.Forms included as references for the project.
The error was due to a Windows Update. Because it does not show any errors on non-updated Windows 7. The error only appears after updating Windows 7
It was difficult to find which update was the reason for the issue. The solution was to install Windows 7 and Visual Studio and never update it. This way, it seems to fix the issue and it does not show the errors anymore.
Reference: https://social.msdn.microsoft.com/Forums/vstudio/en-US/76790023-4d01-43a5-b901-65ad93a5183d/visual-studio-visual-basic-protected-memory-error?forum=visualstudiogeneral&prof=required

Activating Reference in VBA Excel 2010 Project Programmatically

I developed a program in Word and Excel version 2010 using VBA. Within the VB IDE I created a form for which I added a ListView control to. In order to do this I had to open the tools window, right click on it, and select ListView as a component. It then became available to add as a component. It is using the MSCOMCTL.OCX. It functions perfectly on my device, but when I execute the program on another computer, the code raises an object error on the first line that addresses my ListView control:
Run-time error '424'
Object Required
With lvwLog
.ListItems.Clear <--- Error occurs here
.ColumnHeaders.Clear
All the computers in my company are configured/imaged the same way. All are using the same version of office, using Windows 7 Enterprise, and all will have the ListView 6.0 under the component's menu, just not selected. If I were to go into the IDE on the "foreign" computer and open up the form in design, the ListView is not there. You can probably guess that when I add it and name it the same as how my code is addressing it, this will then work on the other computer as designed.
There is no package and deployment wizard available in the Office version of the IDE, and even though I can probably find this, my end users will not go through the process of "installing" an Excel or Word document. If I can't find a way to get this control to register programmatically, then this application I wrote is just not going to get acceptance.
Though we have very few 64bit versions of Office, a different error is raised if opened on a device running the 64bit version of 2010:
System Error: &H80040111 (-2147221231). ClassFactory cannot supply selected class. This appears to be related to the same error, as it errors on the same line of the ListView code. Not sure if once I fix the above if I will need to re-write it in a 64bit version of Office.
Note: "Moving to another computer" simply consists of copying the DOCM or XLTM file to the device and opening it.
After further research I determined that the MSCOMCTL.OCX in the C:\Windows\System32 sub directory on my device was a much newer version than the OCX on the devices in which the code was failing on. This OCX is directly related to the ListView component I was adding to the form.
Once I copied the later version of MSCOMCTL.OCX (version 6.1.98.39, file date 3/31/2014) then the program ran and loaded the ListView control with no errors. Something else I will note is it is not necessary to re-register the OCX if it is being copied to the same system directory and with the same name. Simply copying to the system folder and overwriting the older file will suffice.

How can I browse the classes and methods of an ActiveX DLL?

Basically, what I want to is be able to explore an ActiveX DLL.
I normally fire up VB 6, add the DLL to the "References" of the project, and use Object Explorer.
However, in this particular machine I can't install VB / VS.
I'm sure there's a tool out there that does this. Does anyone know of one?
Thanks
If the machine has Microsoft Office installed, you can go into the built-in Visual Basic for Applications IDE and load the object there:
Tools menu -> Macro -> Visual Basic Editor (or press Alt+F11)
Then when inside the VBA window, Tools menu -> References -> Browse to locate your DLL
and View menu -> Object Browser to view the object's content (or press F2)
I've used Microsoft's OLE/COM Object Viewer for this. It used to be installed with older versions of Visual Studio, and is still part of the Windows SDK.
It also seems to be available separately -- this is from an older version of the Windows SDK, but I don't imagine this tool has changed much recently.
To view the type information for a particular DLL or OCX, File, View TypeLib... is the option you're looking for. You can also dig through the Controls group in the main window to view details on a registered control. Right-click the entry for the control and click View Type Information to see details on the types and methods it exposes.
This will show rather more information than VB6 would. If you're looking at an ActiveX control, the coclass and dispinterface sections of the type library display are the things to look at.
(There's also an Expert Mode option in the View menu -- this will show you pretty much everything stored in the Registry to do with COM, OLE and ActiveX. This is generally rather a lot of information...)
Is it possible to download the component from that machine and examine it locally in Visual Studio? (That'd be my first suggestion.) (And BTW, the .NET versions of Visual Studio also feature a VB6-like Object Explorer which works nicely for this.)
Alternatively, and it's not free, but you might try ActiveXplorer. (I haven't tried this, but it looks promising.) (Discontinued)

Clicking and draggging a user control in VB .NET creates object reference error message

Failed to create component 'User Control 1'. the error message follows:
'System.NullReferenceException : Object reference not set to an instance of an object.
at System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object Component, Object Value)
.............. etc..........
What should I do to fix this error?
When a User Control won't load into the Visual Studio designer here is what you need to do. These instruction are for vb.net project but c# should be similar. Also, before doing this close all open windows (or at least the source and designer files of the control you are working on.)
One last thing. The FIRST thing you should do is ensure that restarting visual studio doesn't fix the problem. If not you can try the steps that follow. These instructions assume that the errant user controls are in control library project in visual studio. If not you should be able to adjust the directions a bit to get it to work but it is much easier when the control is in its own project.
Do the following:
Make the control library your startup project.
Open the properties for the control library project and click on the debug tab.
Under Start Action click the Start external program option and browse to the Visual Studio executable.
NOTE: what this means is that when you run your solution it will fire up another instance of Visual Studio instead of actually running your solution. The First Instance of Visual Studion (INSTANCE_1) will "host" a second instance of visual studio (INSTANCE_2) when you run it.
Run your solution. INSTANCE_2 will load.
Switch back to INSTANCE_1.
In INSTANCE_1 hit CTRL-ALT-E. This will open up the exceptions dialog box. Check On the THROWN column checkbox next to Common Language Runtime Exceptions.
NOTE: This will ensure that INSTANCE_1 will BREAK at ANY runtime error even if it is hit in a try block.
Switch to INSTANCE_2. In Solution Explorer double-click to open the errant user control.
You should find that INSTANCE_1 OF Visual Studio should have stopped at the line of code that caused the designer to not load the control. Fix the code (which usually means testing for IsNot Nothing before references an object properties...but could mean other things.)
Also, sometimes I find that the control WILL load in INSTANCE_2 instead of breaking on an error in INSTANCE_1. In that case just stop debugging...close INSTANCE_2. Save/Restart INSTANCE_1 and your problem will often have gone away.
The lesson is this. User Control MUST be able to load/reference all objects and their members in order to load it into the designer. So for User Controls that will be placed onto other containers I will usually design events to notify the parent rather than trying to push objects into the child control.
Hope this helps for future reference on this old question.
Seth
Instead of the error occurring when you open up a form for editing, it sounds like this is occurring when you are already editing a form and adding new user controls. A CodeProject article that was previously mentioned shows what to do in the case of a form not loading correctly, rather than a specific user control.
Does your user control have any properties that map to custom objects (i.e. not Integer or String)? If so, the Form Designer will attempt to load your properties into the Property Editor. If showing the properties generates an error, the Form Designer will show that to you. I think this is what is happening with your user control.
If you could edit the question and add more information about the nature of the error (more of the error text), it would assist others in helping you better. Alternatively, see if you can find the property that might be causing the error (e.g. whether any property relies on a non-null value being set). You can also take a look at this MSDN article for tips on how to limit the control for just run-time.
Thanks, Seth, for this post! Your solution helped me nail down the error. The only thing I would add to this is that when "INSTANCE_2" loads, you may need to actually load the project file in INSTANCE_2. I needed to because I wasn't dealing with a control library, but instead had custom User Controls defined in the same project that the forms were located in. Once I loaded the project in INSTANCE_2, I opened the erring form and that caused INSTANCE_1 to pop up to the line of offending code in the User Control.
I have found that this error often occurs when control dlls are not building properly. 95% of the time this is remedied by simply restarting Visual Studio.