cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to use class megaroot.

Fabrica_AE
MEGA Partner
MEGA Partner

Hi community. 

I'm working with a macro, and trying to use megaroot in my code, but I'm receiving an error (0x80010105) and also a message that said that is needed an object. Can anyone please, bring me some examples of how to use the class oMegaroot, or megaroot, or megacurrentenvironment? 

Is there any guide or technical information about it? 

Thanks for your help. Regards. 

4 Replies

Thanks for your help oguimard, very useful. 

Regards. 

If you are in a program that launch HOPEX from the OUTSIDE

 

Option Explicit

Dim hopexuserlogin
Dim hopexuserpassword
Dim adminuserlogin
Dim adminuserpassword
Dim sSandboxPassword
Dim Args 

' ---- Environment, database, user, and password information ----

' --- default login and password value to open hopex ---
adminuserlogin = "Administrator"
adminuserpassword = ""

hopexuserlogin = "System"
hopexuserpassword = ""     

' ---- Set Environment, database, user, and password information ----
Dim oMegaApp
Dim oEnvironment
Set oMegaApp = CreateObject("Mega.Application")

Set oEnvironment = oMegaApp.Environments.Item(1)
oEnvironment.CurrentAdministrator = adminuserlogin
oEnvironment.CurrentPassword = adminuserpassword

Dim oDatabases
Dim oDatabase
Dim MyRoot
Set oDatabases = oEnvironment.Databases

Set oDatabase = oDatabases.item("SystemDb")

Dim sConnexionString

' for a classic HOPEX User
' sConnexionString = "#Login=" & hopexuserlogin & ";Password=" & hopexuserpassword & ";Profile=HOPEX Administrator;TranType:Micro;OpenMode:W"

' for system User
sConnexionString = "#Login=" & hopexuserlogin & ";TranType=Private;TranType=Micro;OpenMode=W;SessionMode=SS;Profile=HOPEX Administrator;SystemMode=Y"

Set MyRoot = oDatabase.OpenEx(sConnexionString)

' put you code here 
Dim oColLogins
Set oColLogins = MyRoot.getCollection("....")


' --- Close MEGA ---
MyRoot.MegaCommit
MyRoot.BaseClose
Set MyRoot = Nothing

' ---- Close environment ----
Set oDatabases = Nothing
Set oDatabase = Nothing
Set oEnvironment = Nothing
Set oMegaApp = Nothing

 

Visual Basic. 

Regards

oguimard
Retired

Hello,

 

can you specify which language you are using ?