Are there any valid/working usages of MSForms.Control.RowSourceType property? - vba

An MSForms.Control has a property defined as Property RowSourceType As Integer, but any attempt to read or write the property seems to fail with error:
Run-time error '-2147352573 (80020003)':
Member not found.
Are there (or were there once) any built-in MSForms controls or ActiveX controls for which this property doesn't throw an error?

A quick web search for VBA RowSourceType turns up a bunch of results for VBA Access. I've only dipped my toe into VBA for Access, and that was many years ago, so I can't say how it's used in Access. But I'm guessing that you're using VBA with something else (Excel, Word, etc.). I suspect the generic Control object is used across all application hosts.

Related

Access VBA control reference issue?

I'm trying to loop through all the controls on an Access form but for some reason the controls object is not giving me the correct properties.
When I select and right click on "Control" (in 'As Control') it says "identifier under cursor is not recognized".
I'm thinking it's a reference issue but I can't figure what's missing or incorrect. I don't get any syntax error so Control is a valid object.
I tried decompiling, repair and compacting just to be sure.
The generic control object doesn't have too many useful properties or methods.
It covers also things like lines or subform containers or tab cards, which don't have much in common.
The specific controls like Textboxes have all the properties you are probably looking for.
You still can loop over all controls, and set the usual properties that most controls have, like .Visible or .Locked. Even if Intellisense doesn't provide them.
ctl.Locked = bLocked will work.
But you should handle (On Error Goto) or ignore (On Error Resume Next) runtime errors that will occur, if one control doesn't have the property you want to set.
Bonus question to everyone: why does the generic control object have the .Dropdown method that applies only to combo boxes? Very strange.

How to Edit Custom (Server) Document Properties - Microsoft Word 2013 (VB Macros)

A Microsoft Word 2013 document at work has the Document Information Panel (DIP) displayed by default, with what is listed as "Document Properties - Server".
I'm trying to make a VB Macro that will involve editing these custom properties. However they don't seem to exist in ActiveDocument.CustomDocumentProperties, or ActiveDocument.BuiltInDocumentProperties. I know this because I ran through the list, displaying them one by one, as well as searching them by name.
The first property on the DIP called 'Title' showed up (in the latter list), but none of the other properties. It's worth noting that some are dropdowns, and one is a date with a calendar feature. I should also mention that I get a Run-time error near the end of the list of BuiltInDocumentProperties.
Is there another list where I can access these server properties, or some other issue that I'm overlooking? Any help would be appreciated.
I was able to find them. They are listed in ActiveDocument.ContentTypeProperties

Accessing standard VBA word enumerations

I'm new to VBA. Some tutorials tell me to use enumeration constants such as wdOrientLandscape and wdRowHeightExactly (to change page orientation and make row height 'exact' respectively). However, when debugging, I can see that the value of these constants is Empty and they don't 'work' as expected.
Do I need to do something special to access these constants e.g. add a reference or something?
I'm creating a Word document from an Excel macro.
Thanks in advance
Within Excel (or any automation client) the enumerations belonging to the Word object model are not exposed if you use Late Binding (CreateObject("Word.Application")).
If you early bind by adding a reference they become visible.
If you add Option Explicit to the top of you code modules (or select Require Variable Declarations from the VBA editor options) you will receive a compile time warning if you attempt to use something that's not declared/unavailable
In your particular case, you would want to add the Microsoft Word Object Library to your references. If you choose to early bind. This can be done by going to Tools>>References and checking the appropriate box.

How to identify a specific ActiveX Interface based on limited information

I am in the process of developing an ActiveX control for embedding in Rockwell Automation's Factory Talk View. (See ActiveX DLL Error: Solved to see how great a start I got off to!)
At the moment I have an ActiveX control that seems to embed into the host system OK, but is not fully integrated into the VBA process. I believe that this is because I have not implemented some specific COM interface that is required, but I have no documentation as to what that is. I do know that standard MS controls like the Microsoft Forms 2.0 controls do implement the required interface and fully integrate.
The key functionality I am missing relates to a property that I need to set in order for my VBA code to actually see the ActiveX object. This property can be seen when opening the property panel for any activeX control placed on a Factory Talk screen, but NOT when looking at the properties of ActiveX controls embedded in (for example) Excel. Thus I am probably trying to chase down some custom Rockwell implementation. I am hoping that SO might be able to give me some aid into how to track down what I want based on recognizing the functionality it implements.
Now to the actual property. In Factory Talk the property is called "ExposeToVBA", and has a type "long". You have a choice of 3 values selected from a drop down list:
Not Exposed - When set to this, the controls name is not even visible to VBA code
Type Info Extension - Not sure what this does
VBA Control - VBA code can see and interact with the control.
When I select anything other than "Not Exposed" for my control, I get a warning dialog box with no text on it. For other controls I need to set it to "VBA Control" in order to interact with it in the VBA code (d'oh)
I suspect that the value of this property is translated into some calls to an ActiveX interface on the target control.
The Question
What I want to do is identify what interfaces something like a "Forms 2.0 Label" implements that would match the above functionality. And also perhaps how I could translate this into my C# based control (based on C# ActiveX control (CSActiveX))
I know its a long shot, but I'd appreciate any and all suggestions
This became moot when I found a canned Active-x control that had the functionality that I needed.
FWIW This is what I believe that I used: DMGraph

Is there a way to get full IntelliSense for VBA in Access and Excel 2007?

In VB.NET, the IntelliSense pops up as soon as you start typing which gives you a pretty full list of things you can use at that moment. The IntelliSense in VBA however, doesn't kick on for me until a period is put after the part you're using. For example, I go into the VBA editor in Excel 2007 and start typing the word "Range" but the IntelliSense doesn't come up until I type "Range." after which it will give me a list of things I can use at that point.
Is there any way to make IntelliSense come up sooner in the VBA editor, so that I'm able to see a list of things that can be used like Davg, DCount, etc?
Just press Ctrl + Space at any time in the editor.
No, but you can type Excel first. Put a period after that, and you'll find out more than you ever wanted to know about Excel.
Same with Access. Type Access and a period, and you will find DCount there.
Unfortunately in Excel some objects are declared 'As Object' and Object doesn't have any methods so Intellisense won't be able to display any. The main culprit being Excel.ActiveSheet.
If you know what the type actually is then you can declare it explicitly and assign it to the value you want. EG:
Dim mySheet As Worksheet
Set mySheet = ActiveSheet 'This line would cause a type mismatch error if mySheet was declared as something other than a WorkSheet
mysheet.[All The Intellisense For a Worksheet Pops Up]
VBA is a different beast than .NET so I'm not sure how to bring up the IntelliSense quicker. I find I have the same problem you're having in 2003.
I would suggest checking out the Object Browser though. In 2003, it's View > Object Browser, or F2, in the VB Editor. I find it's a great way to explore the class libraries available. It will show you everything that you currently have referenced and once you reference more libraries, they will also show up in the Object Browser.