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

VBA - Connection details to import data to repository

mrajih
Super Contributor

Hi,

 

I'm trying to create a macro to import data to Mega repository, but I have this error message when launch it :

 

Error message

################################

Compile error:

Method or data member not found

################################

 

My code:

#######################################################

 

' connect to MEGA
sAdmUser = "Gear"
sAdmPwd = ""
sUser = "Gear"
sPwd = ""
sEnvPath = "D:\Program Files (x86)\MEGA\MEGA HOPEX V1R3\GEAR_DEV"
sRepository = "Gear_dev"
Set oMegaApp = CreateObject("Mega.Application")
Set oEnvironment = oMegaApp.Environments.Item(sEnvPath)  ===>> this is what's highlighted
oEnvironment.CurrentAdministrator = sAdmUser
oEnvironment.CurrentPassword = sAdmPwd
Set lTransactions = oEnvironment.Transactions
Set oTransaction = lTransactions.Create(sRepository, sUser)
oTransaction.Password = ""
Set myRoot = oTransaction.Database.Open

 

###################################################

 

Can you please hep?

 

Thank you 

Mehdi

 

 

3 Replies

mrajih
Super Contributor

The solution was the selected libraries withing Excel (on developer view > tools > references).

I have to select "Mega standard library automation components" and not "Mega application automation components" (see screenshot)

 

Hope this help others

 

Thanks

Mehdi

mrajih
Super Contributor

Hi Olivier,

 

The env path is the same as in Megasite.ini.

Is there a different way to connect to Mega repository with R/W access ?

 

Thank you

Mehdi

oguimard
Retired

Hello,

 

there is no obvious error in this code.

 

  • Where do you execute this VB ? in Excel ?
  • Does the path "D:\Program Files (x86)\MEGA\MEGA HOPEX V1R3\GEAR_DEV" is the one defined in the Megasite.iniMake sure in HOPEX when the environment is reference there is no blank space before or after the URL