Posting VBA code

TrippyTom

Well-known Member
Joined
Nov 16, 2004
Messages
587
I was wondering if instead of using the addin to post code, we could use BBCODE like the guys over at VBA Express Portal do to post their code. All they have to do is put [vba] [/vba] around their code and it shows up great (even in color).

Yes, I know the add-in does this too, but it's much faster to use BBCode and those of us who read the forums at work can't install the add-in because of company policies.

Anyway... it was just a thought.
 
Hello,

Have you used the code tags here?

Code:

It doesn't format code in colour, but your code will retain its formatting.
 
yep i have... I just thought it would be nice to see it in color too.
 
Yes,I see you have:

http://www.mrexcel.com/board2/viewtopic.php?p=807812#807812

I won't be writing out the source for that kind of board mod., but if someone wants to provide the source for such a mod., I'd be willing to entertain it.

TrippyTom said:
Yes, I know the add-in does this too, but it's much faster to use BBCode and those of us who read the forums at work can't install the add-in because of company policies.
{snip}

Why can't one install an Excel Add-in? I'm not even sure I like the word 'install' here, they don't modify your registry or anything... Why would someone ban an XLA file? They're no more risky than an XLS file, yes-no?

Frankly it's the VBA in the Add-in that matters, if you can run VBA from where you're sitting, you can generate the HTML code you're looking for. I.e., the Add-in was created for convenience/ease-of-use, but you could use the VBA source code outside of an XLA file. ;)

If you can't run any VBA for whatever reason, the Code tags will have to do for the forseeable future, not that the code will matter to you...

Also, I'm not sure why it'd be faster to use tags of some sort either. You hit the button to copy the code, paste the generated html into the thread, you don't even need to use tags. :confused:


Edit: Okay, it does add an Open option in your reigstry to launch the file when Excel is launched, to be fair. But, I still don't see a security risk from that in itself.
 
test - in BBcode

Public Sub Happy_Birthday()
Dim bday As Integer
For Each bday In life
MsgBox ("Happy Birthday!")
Next
End Sub


test #2 - in html

<font face=Courier New><SPAN style="color:#00007F">Public</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Happy_Birthday()
<SPAN style="color:#00007F">Dim</SPAN> bday <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Integer</SPAN>
<SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> bday <SPAN style="color:#00007F">In</SPAN> life
MsgBox ("Happy Birthday!")
<SPAN style="color:#00007F">Next</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>
Ok, I must be doing something wrong because it didn't give me the indents correctly. This is what I mean by "faster"... I don't have to fiddle with remembering the correct way to post code. BBCode would just handle it automatically.
 
Tom--it's not you, the board does not display the HTML tag correctly. And I don't think the BBCode from the addin has ever been able to handle indents quite right.

There's a teensy fix to the code that will take care of the problem with the HTML option and display the indents, though. I haven't gotten around to actually writing anything up for it, but you can read it here:
http://www.mrexcel.com/board2/viewtopic.php?t=144664
 
Test again

<font face=Courier New><SPAN style="color:#00007F">Public</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Happy_Birthday()
    <SPAN style="color:#00007F">Dim</SPAN> bday <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Integer</SPAN>
    <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> bday <SPAN style="color:#00007F">In</SPAN> life
        MsgBox ("Happy Birthday!")
    <SPAN style="color:#00007F">Next</SPAN>
<SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN>
</FONT>

Thanks so much! The fix works great! Sorry I never noticed your post about it before. SWEET :)
 
TrippyTom said:
The fix works great! Sorry I never noticed your post about it before. SWEET :)

Yeah, it's kind of hidden here in the 'About' forum, now. Honestly, if I wasn't the one who posted it I doubt I'd know about it, either :)
 
Maybe you can just release an update on the add-in so future users won't have to fix it? And you could tell people who already have it to redownload it if you don't want them going into the actual code and messing things up.
 
That is an idea...I have no access to the actual files myself, though. I just messed around with the code on my install of it here until it worked.

I'll ask around and see what could possibly be done about it, though :)
 

Forum statistics

Threads
1,221,625
Messages
6,160,908
Members
451,677
Latest member
michellehoddinott

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top