VBA editor auto-deletes spaces at the ends of lines

前端 未结 17 1302
不知归路
不知归路 2020-11-30 05:11

Is there a way to convince the VBA editor in Excel to stop auto-formatting lines to remove the space at the end when I pause in my typing for a quarter second?

相关标签:
17条回答
  • 2020-11-30 05:29

    Taking it out of design mode fixes it every-time on vba2003 - its was driving me crazy at first ... i did notice it might have something to do with the web control but when i take it out of design mode it works fine ... just toggle that to get it to behave :)

    0 讨论(0)
  • 2020-11-30 05:30

    There is sort of a way to turn off the auto-"correction" in the VBA Editor.

    Tools Menu -> Options -> Editor Tab -> Clear the Auto Syntax Check box

    Sadly, this won't solve all your problems, as the VBA Editor tends to have a mind of its own, for better or worse.

    0 讨论(0)
  • 2020-11-30 05:30

    Something is causing your spreadsheet to recalculate while you are in the VBA Editor and this 'compiles' your code and thus strips the spaces. You need to stop the cells recalculating while you are editing. Turning the calculation to manual in the spreadsheet. Tools > Options > Calculation should do the trick.

    I noticed this when I had cells recalculating thanks to a DDE connection.

    0 讨论(0)
  • 2020-11-30 05:31

    If it helps, none of the previous answers solved mine. Only solution appeared to be to close the xls file and reopen it. Frustrating to have to do every 30 mins but at least it works. Would love to know why it's recompiling and cleaning the text... should really be an option to disable the text cleanup but couldn't find it.

    0 讨论(0)
  • 2020-11-30 05:33

    I have had this same problem several times recently, and has driven me crazy.

    After reading this post all the different fix-ups mentioned (none worked for me), I recalled I have been playing lately with Internet Explorer Control, opening Internet Explorer from VBA.

    This is mentioned in some of the answers in this post.

    This got me in the right path and, in order to fix it, I had to first delete all iexplore.exe instances (alt+control+delete), closed Excel and open excel again. (iexplore.exe had been opened invisible from the VBA code, and I didn't know they were running)

    That fixed the bug.

    I have been programming quite heavily with VBA for over 4 years, and never had this problem.

    Just a couple of weeks ago I started using IE control, and I started getting this problem...so in my case I can only assume the bug is directly related to the IE control.

    I am running both excel 2003 and 2007 in same PC at the same time, and the problem only happens with excel 2007.

    0 讨论(0)
  • 2020-11-30 05:36

    I've definitely had that issue before, where the vba editor would format as I was typing (not just when I went to another line). For me, it seemed to be related to a Microsoft Web Browser control that I had in an open workbook. When I took out the web browser, the VBA editor started acting normally again. I have no idea why that worked, but it did. Now I avoid using that control in my workbooks.

    0 讨论(0)
提交回复
热议问题