Excel User Group
Microsoft Excel blogs, forums, files. Read, ask questions, provide answers.

Posting Code to excelusergroup.org

I have been testing several solutions for posting formatted code to these forums and blogs. There are a few that I can build-in, but I am nervous messing with the code base as we are just getting going.
 
The code below is formatted using Windows Live Writer, a free blogging tool from here. I have added to that an add-in, (there are dozens of them) to insert code snippets. (There are lots of these too).
 
You can just add this as a plug-in very simply and it appears as a link in the right sidebar of WLW. Click on it, paste your VBA code (or other code if you need) and, in VBA's case select VB as the language.
 
You can either set it to be in a container or post the styles with the post.
 
Now the tricks. If you are posting to a blog (even one on www.excelusergroup.org), then you can very easily link to your account there and just post at the click of a button...job done.
 
If you want the formatted code in a forum post, just go to View>HTML Code and copy the post in it's entirety. Now take this HTML to the forum and either start a new post or reply to an existing one and click on the HTML button in the editor and paste the code.
 
Job done, (an example is below, posted in it's 'container', formatted, indented the lot and you can even add line numbers to make navigation or instructions for readers easier)
 
Hope you use it
 
Sub TestPost()
Dim wb As Workbook
Dim wks As Worksheet
Dim myCell As Range
'Assign Object Variables
Set wb = ThisWorkbook
Set wks = wb.ActiveSheet

'Iterate range
For Each myCell In wks.Range("A1:A100")
    If myCell.Value = 1 Then
        myCell.Value = "Do This"
    End If
Next myCell

'Release object pointers
Set wks = Nothing
Set wb = Nothing
End Sub

Posted Jan 22 2008, 10:46 PM by Admin
Filed under: , ,

Comments

XL-Dennis wrote re: Posting Code to excelusergroup.org
on Wed, Jan 23 2008 6:11 AM

Nick,

Very nice! I believe other members need some additional information in order to successfully set it up.

In addition, not everyone is allowed to download and install a desktop tool like WLW so perhaps we need to find other options as well.

Would it be possible for You to set up a test subforum enabling us to test a various options to post formatted code?

Kind regards,

Dennis

hrlngrv wrote re: Posting Code to excelusergroup.org
on Wed, Jan 23 2008 7:22 PM

Gotta reply here since the corresponding forum message is locked, so no responses allowed.

Myself, I prefer plain text and can live without syntax coloring. As for indentation, pasting code straight from the VBE maintains indenting and line spacing, as opposed to written text, which the forums' edit boxes insist on displaying with extra line spacing.

There's ample scope for better per-user settings here.

Admin wrote re: Posting Code to excelusergroup.org
on Thu, Jan 24 2008 3:33 PM

Harlan

I'm not disagreeing with you, it was just we had a request for a code formatter, so in an effort to help everyone...

Also, for information, pressing shift and enter allows single line spacing in normal text

Copyright Excel User Group and the relevant contributors, 2008. All Trade Marks acknowledged. This site is a peer-to-peer site and NOT affiliated in any way to Microsoft Corp. All rights reserved.