36 lines
859 B
Python
36 lines
859 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
import win32com.client
|
|
|
|
|
|
appl = win32com.client.Dispatch("Access.Application")
|
|
appl.visible = 0
|
|
appl.OpenCurrentDatabase(r'C:\Users\Lorenz\Desktop\wgmaster2010.accdb', True, True)
|
|
|
|
dict_modules = {}
|
|
|
|
try:
|
|
comps = appl.VBE.VBProjects(1).VBComponents
|
|
for i in comps:
|
|
name = i.name
|
|
comp = comps(name)
|
|
fname = f'{name}.' + {1: 'bas', 100: 'frm'}[i.type]
|
|
lines = comp.CodeModule.CountOfLines
|
|
|
|
# To jump empty modules
|
|
if lines == 0:
|
|
pass
|
|
else:
|
|
text = comp.CodeModule.Lines(1,lines)
|
|
dict_modules[fname] = [text]
|
|
finally:
|
|
appl.CloseCurrentDatabase()
|
|
|
|
for name, data in dict_modules.items():
|
|
print(name)
|
|
with open(f'dump/{name}', 'wb+') as f:
|
|
txt = ''.join(data)
|
|
f.write(txt.encode('utf8'))
|
|
|