‎12-09-2017 11:29 PM
I have a macro that I am running to export items to excel. when I execute it from within MEGA I get a dialog box that requires user interaction. It says "A process is attempting to access the MEGA repository. Do you accept." The user then has to click yes or no. Is there any way to surpress this messagebox?
Here is the code I use to invoke the MEGA repo:
Dim oMEGAEnv
Dim MegaDB
Set oMEGAEnv = CreateObject("MegaRepository.CurrentEnv")
Set MegaDB = oMEGAEnv.GetRoot
I am not executing this from an object like most macros. So <object>.getroot isn't an option. It's a stand alone macro that we want to run outside of any object.
Solved! Go to Solution.
‎25-09-2017 07:44 PM
Jerome,
Thank you! This is exactly what I needed! As a side note, I originally was just trying to run this in a script window which did not work. I had to create a test macro to give the sub context.
‎25-09-2017 10:04 AM
It is recommended to setup a GUI (menu...) to trigger this processing
Anyway it is likely this message occurs because the 'root' objet (entry point on the current repository) is not identified
In a macro, you can use a function main to get the root
'MegaContext(Fields,Types) Dim oRoot as MegaRoot Dim oCurEnv as MegaCurrentEnvironment Sub Main(Root) Set oRoot = Root Set oCurEnv = oRoot.CurrentEnvironment Msgbox "Count of org-unit: " & oRoot.GetCollection("Org-unit").Count End sub
‎22-09-2017 07:11 PM
Thank you for your reply.
The problem is I am not using the API or an external program of any sort. I have a single, stand-alone macro within MEGA that needs to access objects within MEGA. The macro isn't called from any object or menu. It is just run by the user by either right clicking the macro object and running it or editing it and executing within the script window.
I want the following code to run within a macro without getting the dialog box. I'm not sure if this is a syntax thing or if it is even possible.
Dim oMEGAEnv
Dim MegaDB
Set oMEGAEnv = CreateObject("MegaRepository.CurrentEnv")
Set MegaDB = oMEGAEnv.GetRoot
Set oMEGAEnv = nothing
Set MegaDB = nothing
‎20-09-2017 10:32 AM
A token here is a string used to authentice a process
Example of string: EnableExternalOpen
You need to do 2 item
1) From the running instance of HOPEX, run a macro that creates a token
Example: example macro called by popup menu item, toke is named here
Sub CmdInvoke(mgobjSource as MegaObject, intCmdNumber as Integer)
Dim oRoot as MegaRoot
Set oRoot = mgobjSource.GetRoot()
oRoot.SetOpenToken("EnableExternalOpen")
Msgbox "Token created"
End Sub
2) In the code of the external application using API, quote this token to avoid the standard warning
Set MyRoot = oCurEnv.GetRoot("EnableExternalOpen")
‎19-09-2017 07:29 PM
I've tried this before and it doesn't work. I may be missing something but here is the exact code I am running in the script editor and it fails. It is mostly copied from the link you posted.
GetRoot.SetOpenToken("test")
Dim CurEnv As MegaCurrentEnvironment <-Errors here
Dim MyRoot As MegaRoot
Set MyRoot = CurEnv.GetRoot("test")
Set CurEnv = Nothing
Set MyRoot = Nothing
Here is the error it is throwing:
Script Editor Default : Microsoft VBScript compilation error line 4, offset 12 :
Error(0x800a0401) : Expected end of statement
The link talks about creating the token in MEGA and calling it from an external script. I need this MEGA macro to be called and run within MEGA without the access dialog. If this isnt possible then I need to know that as well.
‎15-09-2017 11:21 AM
Hello
This message is a security warning: it enables identification of calls to MEGA via API scripts allowing the user to refuse execution of possibly malicious programs.
If you know that this message corresponds to execution of a friendly program using API script answer Yes. If not answer No.
To avoid this message at execution of the API program, use the method SetOpenToken
See documentation and this KB http://community.mega.com/t5/custom/page/page-id/mega-kb-solution?sid=50120000000mqazAAA