Closed Alfonsomazzarella closed 1 year ago
The import logic is in the following file: https://github.com/rubberduck-vba/Rubberduck/blob/next/Rubberduck.Core/UI/CodeExplorer/Commands/ImportCommand.cs
As far as I can tell from my phone (and before drinking my first coffee) we explicitly call Import on the relevant VBComponent obtained from the underlying VBProject obtained from the VBE we're hooked into. Special component files (i.e. documents and some others) are imported using the ImportSourceFile function instead.
To expand on what @Vogel612 said, that basically means change:
Application.loadfromtext content
To the richer:
Application.VBE.ActiveVBProject.VBComponents.Import "C:/foo/file.bas"
That works for classes and standard modules.
Documents/forms need some special handling though (as pointed out above, in the ImportSourceFile
function:
And ultimately falls back to:
VBComponent.CodeModule.AddFromString content
Hello,
i have a script that export one full project with Applications.saveastext (every type of file .bas, .cls, .form, .qry, ecc) and it does it right. Then i have another script that should import everything back with Application.loadfromtext and it works, but some attributes are deleted and i don't understand why. Not every attribute, just some of them and i'm talking about the attributes description.
So when i use loadfromtext this Attribute is deleted.
BUT
When i use the "Add-> Existing Files" offered by rubberduck ide it does work and it does keep the attribute. That's why i'll be happy to understand how rubberduck can do that.
Thanks in advance and sorry for my english :)