Example #1
0
def lift_vba_function(xl, workbook, ast, fname):
    assert fname in ast.function_namespace

    # Create a code stub that handles proxying of VBA return
    # value into Python.
    test_stub = _create_function_test_stub(ast.function_namespace[fname])
    ast.code.append(test_stub)

    project = VBProject()
    project.add_reference(*SCRIPTING_REFERENCE)
    export.add_procedural_module_to_vbproject(project, ast)
    for module in project.modules:
        print module.name
        print module.code

    import_vbproject(workbook, project)

    def lifted(*args):
        resultdict = Dispatch('Scripting.Dictionary')
        xl.Run(test_stub.name, resultdict, *args)
        return resultdict['ReturnValue']
    return lifted
Example #2
0
def test_import_vbproject(tmpdir, xl):
    m1 = Module('StandardModule', STANDARD_MODULE_CONTENTS)
    m2 = ClassModule('ClassModule', CLASS_MODULE_CONTENTS)
    project = VBProject([m1, m2])

    wb = xl.Workbooks.Add()
    components = import_vbproject(wb, project)

    assert components[0].Type == const.vbext_ct_StdModule
    assert components[0].Name == 'StandardModule'

    assert components[1].Type == const.vbext_ct_ClassModule
    assert components[1].Name == 'ClassModule'
Example #3
0
def test_import_vbproject(tmpdir, xl):
    m1 = Module('StandardModule', STANDARD_MODULE_CONTENTS)
    m2 = ClassModule('ClassModule', CLASS_MODULE_CONTENTS)
    project = VBProject([m1, m2])

    wb = xl.Workbooks.Add()
    components = import_vbproject(wb, project)

    assert components[0].Type == const.vbext_ct_StdModule
    assert components[0].Name == 'StandardModule'

    assert components[1].Type == const.vbext_ct_ClassModule
    assert components[1].Name == 'ClassModule'
Example #4
0
def lift_vba_function(xl, workbook, ast, fname):
    assert fname in ast.function_namespace

    # Create a code stub that handles proxying of VBA return
    # value into Python.
    test_stub = _create_function_test_stub(ast.function_namespace[fname])
    ast.code.append(test_stub)

    project = VBProject()
    project.add_reference(*SCRIPTING_REFERENCE)
    export.add_procedural_module_to_vbproject(project, ast)
    for module in project.modules:
        print module.name
        print module.code

    import_vbproject(workbook, project)

    def lifted(*args):
        resultdict = Dispatch('Scripting.Dictionary')
        xl.Run(test_stub.name, resultdict, *args)
        return resultdict['ReturnValue']

    return lifted