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

VBscript to import a xml or xls file to mega

gonzalogtz
Super Contributor

Hi! Im starting to use the script editor en mega and i found out how to export objects using this code:

 

Set oBP=GetCollection("Software technology")
oBP.CallMethod("~Bav0cNnAjyQR[Standard for export]").SaveAs "C:\Desktop\MegaExport.xml","CommandFormat=XML"

 

and i have been searching and reading the import documentation but i dont understando how to import a file that contains objects to mega.

Is there a simple code like the one above for importing?

 

Thanks!

3 Replies

 

In the above example, MyDb is a MegaDatabase object that you can get in a Administration script from the collection MegaDatabases on a MegaEnvironmentObject

See for example KB http://community.mega.com/t5/custom/page/page-id/mega-kb-solution?sid=501D00000014PFaIAM

 

If you want to run the import from the script editor in a private workspace, the context is different because the repository is implicitely the current repository

In this situation:

  • Create a MegaRoot object with GetRoot function
  • Import a .MGR file with the MegaImport function (2 mandatory parameters: import file, reject file)

 

Code example (VB script)

Set oRoot = GetRoot()
oRoot.MegaImport "C:\tmp\import.mgr","C:\tmp\rejects_import.mgr"
Jerome

Thank You Jerome! i´ll give it a try! 

I just have a doubt, how do you declare the mydb object?

 

Thanks!

jhorber
MEGA
MEGA

There is a function Import on a MegaDatabase object

 

MyDb.import "C:\temp\test_import.mgr","C:\temp\test_rejimport.mgr", "Meta=Off,Technical=Off,Data=Full"
Jerome