Exported VBA
This commit is contained in:
32
wgmaster/wg2.py
Normal file
32
wgmaster/wg2.py
Normal file
@ -0,0 +1,32 @@
|
||||
|
||||
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'))
|
||||
|
Reference in New Issue
Block a user