Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically indenting VBA code.

Status
Not open for further replies.

cadcoke5

Technical User
Oct 29, 2010
4
US
I am on Office 2010, and years ago in an earlier version, I used to be able to use add-ins while I was using the VBA editor. This was for things like automatically formatting the program code with indents, etc.

However, now there don't seem to be any add-ins available. When I go to the Microsoft sight that refers to these add-ins, the link just takes me to a generic download page. But, I have been unable to find these add-ins there. Another site refers to the default add-ins that were included with VBA in office. But, again, I have not been able to find these add-ins. A general internet search tends to give me a million responses about adding add-ins to specific applications like Excel. I have attempted to filter those out, but have not succeeded in my search for information on this.

It may be that Microsoft took them away, in hopes that adding annoyances will somehow encourage the user to upgrade to a more current. though for me, manufacturing these annoyances is no way to make people think that being your customer is a good thing. But, they have certainly done this with the Window 10 nag, and even tricked many into installing it.

I have also been hesitant to get this sort of tool from a 3rd party, for fear of getting infested with a virus. I have seen one paid version, but none free.

Can anyone tell me how to get these add-ons from Microsoft into my VBA editor? Or alternatively, a source for a free plug-in.

Thank you very much,

-Joe
 
Hi,

I've always used the native VB Editor features. I like to indent (TAB) based on code structures. So when I use an If...Then...Else...End If, I add the entire structure immediately as...
Code:
'
   If a = b Then

   Else

   End If
...and then fill in the True and False required code.

Likewise for With...End With, For...Next, Select Case...End Select, etc. Code the structure first. Fill in between next.

Therefore, I rarely get into the bind of trying to find a missing End If, for instance. And I have never wanted for anything more "automatic."

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
The only exception to Skip's opinion would be to format somebody else's code, which I have done on many occasions just to see what the heck is going on in the code / logic. Which is not a big deal - highlight a portion of code and hit Tab (Shift-Tab moves the code 'backwards'- to the left)

cadcoke5 - why do you need the 'automatic' way to format VBA code?

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
When structuring someone else's code or not, one can Select multiple lines of code and then TAB or SHIFT TAB to indent/unindent blocks of code.

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
Thank you all for the replies.

In regards to taking away things that originally were part of a program, even if they were not put onto the individual's hard drive is dishonest. That is selling a product, and then taking part of it away. It's like selling someone a car, but putting an expiration date on when the radio will be disabled. I suppose it is OK if you warn the customer in advance. But, if you don't make this perfectly clear, you are cheating the customer.

In my case, I was aware of the options for formatting my VBA code that you all have mentioned Right now, I am doing a lot of editing of my own code. The challenge is when there is extensive editing, and you want to make sure you got your nested loops correct, and didn't miss something. That is when the automatic indenting is useful.

-Joe
 
I don't recall Office ever coming bundled with such tools for VBA. Perhaps you could provide a link that shows what used to be included.
 
Sorry, I don't recall the details. However, one of the pages I came across on Microsoft's web site did refer to them as being available from Microsoft. The link they provide just doesn't take you to any web page that has them. Rather it takes you to a generic download page. But, that page's search tool does not seem to provide any add-ins for VBA. That is why I was speculating that it was quietly taken away.

-Joe
 
Sorry, I still beg to differ, I've been using and programming the Office applications on Windows since they were individual applications, not a bundle, and before VBA was even included in most of them. At no point do I recall Microsoft ever bundling any tools that might automatically format VBA program code with indents. The closest thing was a tool for helping with code commenting, which was included in the Office 2000 Developers edition. There were 3rd party tools, e.g. Steve Bullen's Smart Indenter, that were available (originally released back in 1998 for all the Office apps that used VBA because they didn't have that functionality, and made available since then because Office VBA IDE continued to lack that specific functionality, although I think last version officially supported was Office 2003), that were available, but Microsoft didn't bundle them with Office. And a quick look at the Wayback Machine certainly seems to confirm my recollections.

Are you quite sure the page you found actually referred to Microsoft add-ins, or perhaps instead to 3rd party add-ins? If the latter, you'll accept, I presume, that Microsoft cannot be held responsible for 3rd party add-ins, and whether they are available for the latest versions of Office or not.

MZ-Tools, mentioned above by MajP, is pretty good (but not free) and these days offers indenting features for VBA (earlier versions only offered it for the full VB programming language development environment)
 
I will accept your statement about VBA not having these add-on included, since I am not that experienced.
Perhaps it was a 3rd party one, and I forgot that fact. So, then MS would have no responsibility.

I tried to find the page where I found a link to download some ad-ins, to verify that this really is what it was. But I didn't find it in a few minutes, so just gave up.

There are, however other things, such as in Word, where the ability to search for clip-art was either removed, or simply broke and not fixed. I suppose every cloud service will eventually go away.

Thanks for the replies. At least I know to stop looking.
 
>Word, where the ability to search for clip-art was either removed

Um, my copy of Word 2010 still has the ability to search for clip art ...

>I suppose every cloud service will eventually go away

There is that risk.
 
It shore would be nice if they did put some effort into VBA. If you work in Visual Studio you can see what is possible. I think VS is a pretty impressive development environment.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top