0

We use the SaveAsText to export vba code from an access database to a textfile and put this file into an svn-database. See here: Extract VBA-Code from Access via C#

The problem is, that VBE (= the VBA Development enviroment) seems to change a lot of stuff in the background. For example:

xerrdesc = Err.Description

is changed to:

xerrdesc = Err.DESCRIPTION

in dozens of modules.

We where not able to find out why the VBE changes this. For us it looks quite random. Sometimes the stuff is changed to capital letters like in the example. Sometimes its changed to lowercase letter and so on.

The result is some kind of "noise" in the repository. There are a lot of changes we did not intend.

Is there a way to prevent the VBE from changing code in the background?

Gener4tor
  • 414
  • 3
  • 12
  • 40

2 Answers2

3

If you

Dim DESCRIPTION As String

anywhere in your Access project, the VBE will "helpfully" change all references of the text "description" to upper case for you. To test this out, type the following in a module where you have your Err.DESCRIPTION text:

Dim Description As String

Then delete that line. It will fix the capitalization everywhere.

Thereafter, just ensure that you're not using "funky" capitalization of any reserved word or method or property of any referenced library.

Just for fun:

Dim value As Long
ActiveWorksheet.Range("A1").value

Note the case of the method .Value has been "fixed" for you. (Yeah, it's Excel, but it'll work the same in Access.)

FreeMan
  • 5,660
  • 1
  • 27
  • 53
  • Im quite sure, that the vbe does also start a "global change" when you just "touch" a already written line. We are talking about >100 projects with 50-150 modules each. So I cans see how its possible to ensure everyone uses the same capitalization all the time... – Gener4tor Sep 26 '18 at 15:11
  • I don't disagree with you @Gener4tor, unfortunately, that's what you get. – FreeMan Sep 26 '18 at 15:17
  • Sometimes it won't change a line until you change something on that line yourself, and it is re-parsed. Then the case suddenly changes. I don't miss VBA :D – HardCode Sep 26 '18 at 17:20
0

ok, the question seems to be asked already:

See here: Annoying vba naming behaviour and here: How does one restore default case to a variable in VBA (Excel 2010)?

sry...

Gener4tor
  • 414
  • 3
  • 12
  • 40