0

I am wondering is there a way to handle the whole process with VBscript? I have an M-Files and in VBA I am able to select the reference

enter image description here

After that I can use M-Files API commands to execute the code.

Dim oVaultConnections As MFilesAPI.VaultConnections
Dim oDocumentCollectionOVAP As New MFilesAPI.ObjectVersionAndProperties
Dim oOldDocumentOVAP As New MFilesAPI.ObjectVersionAndProperties
Dim oMFClientApp As New MFilesAPI.MFilesClientApplication

On Error Resume Next

    Set oVault = oMFClientApp.BindToVault(szVaultName, 0, True, True)

If Err.Number <> 0 Then

    ' Error
    Err.Number = 0

    Set oVault = oMFClientApp.BindToVault(oMFClientApp.GetVaultConnectionsWithGUID(szVaultGUID).Item(1).Name, 0, True, True)

   If Err.Number <> 0 Then
        MsgBox "Can't connect to M-Files"
        End
    End If

End If

On Error GoTo 0

On Error GoTo ErrorHandler1

What about VBScript? What if I would like to create VBS file and perform all the actions with VBScript without need of VBA (for Example Excel file)?

In VBScript I have to get all objects by something like:

Set MFiles = CreateObject("Scripting.MFiles")

Is it possible somehow to get it by location of dll? What if my version will change from 19.9.8227.13? Path will be different?

user692942
  • 16,398
  • 7
  • 76
  • 175
10101
  • 2,232
  • 3
  • 26
  • 66
  • 2
    If the object is accessible through COM you should be able to reference via it’s progid, for example `Set oMFClientApp = CreateObject("MFilesAPI.MFilesClientApplication")`. For more information about how progids work on how to locate them see [this answer](https://stackoverflow.com/a/35985827/692942). – user692942 Nov 15 '19 at 07:33
  • Ok, I will try this one! Thank you! – 10101 Nov 15 '19 at 09:51
  • 1
    I suppose you have a reason to be worried, that TLB name is not a ringing endorsement that the author knows how versioning works in COM. But nothing you can do about it, just make sure to keep a copy of the installer in easy-to-find place. – Hans Passant Nov 15 '19 at 12:41

0 Answers0