Comments (12)
We hit this bug in the Rubberduck project a while back. You may want to browse our source to see how we handled it. If you have trouble finding it, let me know and I'll lend a hand.
from vba-ide-code-export.
Ok, something I have never noticed before, may have had it happen but never noticed really. This can be problematic for this situation though, maybe we could use some of the CodeModule
functions?
Like the example here, a straight copy pasta
from the modImportExport.bas
Set modCodeCopy = comNewImport.CodeModule
Set modCodePaste = comExistingComp.CodeModule
modCodePaste.DeleteLines 1, modCodePaste.CountOfLines
If modCodeCopy.CountOfLines > 0 Then
modCodePaste.AddFromString modCodeCopy.Lines(1, modCodeCopy.CountOfLines)
End If
Project.VBComponents.Remove comNewImport
No, that's not going to work very well as you'd need to go through all the files
🤔
I'll come back on this
from vba-ide-code-export.
Oh, actually I withdraw that comment. It is still there
VBA-IDE-Code-Export/modImportExport.bas
Line 276 in 6eedda7
from vba-ide-code-export.
Related bug report:
https://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_windows8/excel-vba-bug-importing-a-form-adds-a-newline-at/f8901ff1-68d1-40c5-b41d-4b87a0f9db8e
from vba-ide-code-export.
Argh, I must has glossed over that part at some point and left it out. Worth a try.
from vba-ide-code-export.
But yes, maybe there is a hack using CodeModule functions that we could conjure up to solve this problem.
from vba-ide-code-export.
Yeah, it's going to be some ugly loop through all modules, check for whitespace
which will seem overkill but either that than have 15,000 empty lines at the start of your code I guess
I think the thing with this is that in the most part it's a straight import export with forms, why change it gah! Annoying!!
We have to do a whole new thing, to get around an annoying thing, thanks Microsoft
from vba-ide-code-export.
Yes. In the mean time, it can be fixed using a text editor. I usually try to check the git diff
before committing and touch up the whitespace with a text editor if needed. I do this as a routine to remove trailing whitespace as well.
from vba-ide-code-export.
Thoughts about implementation:
The whitespace is added between the attributes and the rest of the code. The attributes "header" seems quite different from the rest of VBA syntax so it seems possible that we could identify the end of the attributes section automatically and simply remove whitelines before the first non-whiteline.
This could be part of a grander "formatting" code which also removes trailing whitespace (this would be quite useful).
Edit: May be useful to look at VBADeveloper's formatting code for inspiration.
from vba-ide-code-export.
Hi @rubberduck203 thanks for taking a look, @mattpalermo I'll let you take a look at this one if you know what needs doing??
from vba-ide-code-export.
Thankyou @rubberduck203 for this. I'll definitely have a look.
from vba-ide-code-export.
Not sure if it's still relevant, but this is the relevant code in Rubberduck:
Note that this creates another problem - member attributes get wiped out, since the module isn't really imported, but re-written. You'll need another mechanism in place to avoid losing the member attributes (we've fixed that as well in Rubberduck, but that's pretty involved).
from vba-ide-code-export.
Related Issues (20)
- Tidy file structure HOT 12
- Syntax error in JSON configuration will raise an error
- Cannot run import twice in a row HOT 4
- Code "formatter" to fix whitespace issues
- Ribbon UI HOT 1
- CustomUI.xml (Ribbon UI) injection HOT 5
- Command line interface HOT 3
- Store Excel workbooks as Unpacked stack of XML files HOT 8
- README Improvements HOT 4
- Keep a changelog HOT 7
- Test and example workbooks HOT 4
- Build a wiki HOT 6
- Set VBAProject Name on Make Config File HOT 2
- Recommend using .gitattributes, .editorconfig and .gitignore files HOT 6
- XML to Excel
- `Add References` clearly detailed in the code HOT 1
- Deletion of macros' components after export of code HOT 6
- Installer is missing HOT 5
- File type check before Excel to XML
- Error 57101 - Can't remove default reference
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vba-ide-code-export.