Hi Scott:
I can get SCF.dll build 3044 to partially work, but not usefully, and there really isn't enough doc to figure out how your automation objects are supposed to work from an automation client. Not the least problem is that I'm unclear what SCF interfaces to -- does it try to talk to the running app (like how all the Office products work), or is it a totally stand-alone thing that interacts only with files, and/or builds models in memory? Certainly when I engage SCF I don't see MR appear in the Task Manager (and having MR running doesn't seem to make things work better).
Anyhow, here's what I tried, and what failed.
Environment: Windows XP SP2.
1. Uninstall previous edition of MR (I think it was 3042).
2. Install 3044 (at different path).
3. Start a VBA project in Excel, and try to use the Tools > References procedure to enable use of SCF.dll. It appears in the list (SCF 1.0 Type Library), however OK'ing that results in "dll not available" error. Maybe registry still has path to uninstalled dll.
4. Run regsrv32 on SCF.dll. Indicates success.
5. In VBA try References procedure... success. Can browse SCFLib objects in Object Browser.
6. Proceed to adapt the sample routine from Help into VBA, as follows:
-----------------------------------------
Sub Test()
Dim Framework As ScriptFramework
Dim Models As MRModelCollection
Dim Model As MRModel
Dim Tables As MRObjectCollection
Dim Table As MRObject
Dim PropValue As MRPropertyValue
Dim V As Variant
Set Framework = CreateObject("SCF.ScriptFramework")
Framework.Initialize ' <-- Apparently needed
'--------- 1. Try ActiveModels ----------
' Set V = Framework.ActiveModels ' <-- returns Nothing
' Set Models = V
' Set Model = Models.Item(1)
'--------- 2. Try CreateModel ----------
' Set Model = Framework.CreateModel ' <-- Error
' Unable to load library DBFMySQLFE, 126
'--------- 3. Try LoadModel ----------
Set Model = Framework.LoadModel(APath) ' APath is a legit wer file
Debug.Print Model.Name, Model.ID ' Succeeds
Model.BeginTransaction ("Batch Rename Tables")
Set V = Model.AsObject.Children("Table") ' Error 80010108
' Method Children of ISCFObject failed
For Each Table In Tables
Set PropValue = Framework.CreatePropertyValue("Table", "Name")
PropValue.FromString ("T_" + Table.Name)
Table.SetProperty "Name", PropValue
Next
Model.EndTransaction
End Sub
-----------------------------------------
This compiles (with Option Explicit), but falls down in various ways.
First off, it took several hours to guess that Framework.Initialize is needed. Not sure why newly constructed Fraemwork needs initializing, but without it pretty much nothing works, and some Framework methods cause hard crash in VBA/Excel.
But, assuming Initialize is the right thing to do...
As you can see, I tried three different Framework methods:
-- ActiveModels: consistently returns VBA Nothing (ie: nul). Perhaps ActiveModels only applies to the running app, and hence to scripting within the app?
-- CreateModel: Always fails with error shown
-- Load Model: Succeeds, and can then proceed to read Model.Name and Model.ID. However, Model.AsObject.Children fails. with error shown. I tried rearranging like this:
Dim MRO As MRObject
Set MRO = Model.AsObject
Set V = MRO.Children("Table") ' <-- Hard crash VBA/Excel
MRO gets a non-Nothing value, but MRO.Children crashes.
7. In VBA Object Browser I see that ActiveModel returns type "Unknown". This article at MS:
http://support.microsoft.com/kb/q194913/
seems to say that "Unknown" in Object browser means a type incompatible with VBA/VB. By contrast, Object Browser shows that CreateModel returns "Object", but as noted above, attempting to use that method causes a crash.
8. I tried interfacing to SCF.dll from Delphi. Delphi was able to import SCF's type library with no problem, and creates an interface with a more detailed view of types than VBA Object Browser. I basically got the same results using equivalent Delphi code. At this step:
-----------------------
Unk := Model.AsObject;
MRO := Unk as MRObject;
Unk := MRO.Children('Table'); // <-- Exception
Tables := Unk as MRObjectCollection;
-----------------------
.. I get an exception showing access violation in SCF.dll at 00BC4C50, read of address 0000018. (Ie: same spot where VBA crashed.)
9. Dependency Walker on SCF.dll: It continues to show various dependencies not found, like MFC80.DLL and numerous friends. It would be nice to know whether SCF is capable of functioning properly if those dependencies are broken.
==============================
Suggestions for progress:
------------------------
Sample code: I feel like there's way too much guesswork for me to troubleshoot this effectively. What would be great is some simple VBA sample code that you guys have seen working, and a description of the test setup required.
Anyhow, I hope that helps,
Graham