Results 1 to 15 of 15
  1. #1
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Posting Code (VBA)

    I have been often frustrated when copying code from the lounge to the VBE to find the carriage returns had all disappeared.

    Recently I came across a post which had the code displayed exactly as found in the VBE; and it copied across perfectly.

    A crude example follows.

    <div style="width: 100%; background-color: #FFFFFF;"> <font color=blue>Option Explicit
    Sub</font color=blue> DisplayDemo()
    <font color=448800>'This is how the posted code appeared</font color=448800>
    MsgBox "Text for the message."
    <font color=blue>End Sub</font color=blue>
    </div hiblock>

    I have since been unable to locate the post, to ask the author for information on how this effect was achieved.

    If anyone recalls this or a similar post, I would appreciate a pointer.

    T.I.A.
    Regards
    Don

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Posting Code (VBA)

    Do you mean something as simple as...

    <font color=blue>Option Explicit</font color=blue>
    <font color=blue>Sub</font color=blue> DisplayDemo()
    <font color=448800>'This is how the posted code appeared</font color=448800>
    MsgBox "Text for the message."
    <font color=blue>End Sub</font color=blue>

    This was created by entering the following text in the browser window.
    <!t>[blue]<!/t>Option Explicit<!t>[/blue]<!/t>
    <!t>[blue]<!/t>Sub<!t>[/blue]<!/t> DisplayDemo()
    <!t>[green]<!/t>'This is how the posted code appeared<!t>[/green]<!/t>
    <!t>[tab]<!/t>MsgBox "Text for the message."
    <!t>[blue]<!/t>End Sub<!t>[/blue]<!/t>

    StuartR

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Posting Code (VBA)

    Also see <post:=346,967>post 346,967</post:>.

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Posting Code (VBA)

    Hi Don,

    I think it depends on how the code was formatted for posting. It could be done in-line, with tagged tabs for indenting, posted with a 'code' tag, or posted with a 'pre' tag. If it's done with the latter, indenting etc is preserved in the post, but line feeds are lost if you copy & paste direct from the lounge into the VBE. I find that pasting the code from the Lounge into a blank Word document (but not Notepad), tnen copying from there to the VBE overcomes the line-feed loss that occurs with code pasted straight from the lounge into the VBE.

    Unfortunately, it can be hard to tell which post format was used, so I just filter any code i copy from the Lounge through Word. For example:

    With 'pre' tags-
    <pre>Option Explicit
    Sub DisplayDemo()
    'This is how the posted code appeared
    MsgBox "Text for the message."
    End Sub</pre>


    with 'code' tags (and 'tab' codes to preserve indeting)-
    <code>Option Explicit
    Sub DisplayDemo()
    'This is how the posted code appeared
    MsgBox "Text for the message."
    End Sub</code>
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Posting Code (VBA)

    Didn't we do some experimenting with code formatting+colouring using a new tag a long time ago?
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Posting Code (VBA)

    Yes; the original attachments were lost in the server crash of last year, but Alan Miller reposted it in <post:=709,509>post 709,509</post:>.

  7. #7
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Posting Code (VBA)

    On the ball as always, I see! <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

    Alan

  8. #8
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Posting Code (VBA)

    Hello Hans
    I am now somewhat confused (a common condition these days). Am I to take from your lack of an admonition here, that the add-in posted by Alan is acceptable for use in posting to the Lounge; or does your caution at <!post=this post,709485>this post<!/post> still hold?
    <!post=This,709511>This<!/post> is so much easier to understand, that it would be a useful server side addition. <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>
    Regards
    Don

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Posting Code (VBA)

    The code attached to <post:=709,509>post 709,509</post:> was written specifically for Woody's Lounge, so you can use it to post code here.

    Since it's very easy to run the code in the Visual Basic Editor, implementing it in the Lounge itself seems unnecessary.

  10. #10
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Posting Code (VBA)

    Don

    The XLA produces both HTML code as well as BB (bulletin board) code. After hacking it, the latter incorporates tags the same as those used in Lounge posts, so you can use it here no probs. You can't post in HTML here though. I doubt it could be included server-side either, because it relies on VBA itself to "do its stuff".

    Alan

  11. #11
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Thank You Gents

    Hans and Alan
    Thank you both for your patience and support. To say "I am delighted.", would be a terrible understatement. <img src=/S/clapping.gif border=0 alt=clapping width=19 height=23>
    Regards
    Don

  12. #12
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Thank You Gents

    All part of the service, Don. It's just one of the ways that your hefty membership fee justifies our handsome remuneration packages. <img src=/S/liar.gif border=0 alt=liar width=25 height=22>

    Alan

  13. #13
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Thank You Gents

    <hr>your hefty membership fee <hr>
    I am deeply indebted to the lounge for the support that has been provided these past few years. This support has allowed me to be seen as a local guru (unjustified).

    I hope to repay this debt of support in part by assisting others through the Lounge.

    In the words of Tony the tiger; "IT'S GREEEEEAAAAAAT". We all owe Woody a vote of thanks for initiating this superb site.
    Regards
    Don

  14. #14
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Thank You Gents

    No arguments there. The Lounge is <big><big>THE</big></big> place to be.

    Alan

  15. #15
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Thank You Gents

    I'll second that!! Maybe one day, i'll have the knowledge and confidence to help others in the way others help me!! This truly is a superb place for finding all things 'pc'.

    <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15> to you all!!

    Nathan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •