refreshing a table in m files admin via VBA

hi all hope everyone is having a great day I'm looking for an excel vba that would open my m files admin and refresh my customer table automatically instead of me having to right click on my customer table from the meta data and click refresh.

Thanks any answers are very appreciated 

Parents
  • Is this an external object type?

    If so then you can use this method: M-Files API - RefreshExternalObjectType Method

  • hi what would be the full vba code in excel the first part i have below 

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Sub RunExternalProgram()
    Dim programPath As String
    programPath = "C:\Program Files\M-Files\24.9.14055.3\ServerTools\MFAdmin.msc"
    Dim objShell As Object
    Set objShell = CreateObject("WScript.Shell")
    objShell.Run "mmc """ & programPath & """", 7, False
    End Sub
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    what would i put as the second part of the code i do have the m files api library installed 

Reply
  • hi what would be the full vba code in excel the first part i have below 

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Sub RunExternalProgram()
    Dim programPath As String
    programPath = "C:\Program Files\M-Files\24.9.14055.3\ServerTools\MFAdmin.msc"
    Dim objShell As Object
    Set objShell = CreateObject("WScript.Shell")
    objShell.Run "mmc """ & programPath & """", 7, False
    End Sub
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    what would i put as the second part of the code i do have the m files api library installed 

Children
  • Hang on.  Sorry, maybe I went too far too quickly.  I strongly suspect that scripting M-Files Admin is *not* what you want to do.  Let's step away from that approach.

    Can you start from the beginning?  Show me exactly which "customer table" you want to refresh.  Can you show a screenshot?

  • see pic below its a custom table that gets updated via an excel sheet

    I already have an excel macro that formats my excel table in a way that m files can update their table all i want is excel to also do the right click and refresh  

  • The method I gave you is the correct one, but you will need to connect to the vault to be able to run it.  You need to have a few steps in your VBA:

    1. Connect and authenticate to the vault.  Maybe use a client connection: Connecting and Authenticating (m-files.com)
    2. Execute the RefreshExternalObjectType API method I mentioned above ("Vault.ObjectTypes.RefreshExternalObjectType(123, MFExternalDBRefreshType.MFExternalDBRefreshTypeFull)")

    Can you try that and see how far you get?  I appreciate the sample code I linked at #1 is in C#, but hopefully you can follow the general process.