Giter Club home page Giter Club logo

Comments (12)

rubberduck203 avatar rubberduck203 commented on August 10, 2024 3

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.

spences10 avatar spences10 commented on August 10, 2024 1

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.

mattpalermo avatar mattpalermo commented on August 10, 2024 1

Oh, actually I withdraw that comment. It is still there

Set modCodeCopy = comNewImport.CodeModule

from vba-ide-code-export.

mattpalermo avatar mattpalermo commented on August 10, 2024

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.

mattpalermo avatar mattpalermo commented on August 10, 2024

Argh, I must has glossed over that part at some point and left it out. Worth a try.

from vba-ide-code-export.

mattpalermo avatar mattpalermo commented on August 10, 2024

But yes, maybe there is a hack using CodeModule functions that we could conjure up to solve this problem.

from vba-ide-code-export.

spences10 avatar spences10 commented on August 10, 2024

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.

mattpalermo avatar mattpalermo commented on August 10, 2024

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.

mattpalermo avatar mattpalermo commented on August 10, 2024

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.

spences10 avatar spences10 commented on August 10, 2024

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.

mattpalermo avatar mattpalermo commented on August 10, 2024

Thankyou @rubberduck203 for this. I'll definitely have a look.

from vba-ide-code-export.

retailcoder avatar retailcoder commented on August 10, 2024

Not sure if it's still relevant, but this is the relevant code in Rubberduck:

https://github.com/rubberduck-vba/Rubberduck/blob/2b341dd15605cbca037f3d5f7c50ef83fedc7c3b/Rubberduck.VBEditor.VBA/SafeComWrappers/VB/VBComponents.cs#L133-L150

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.