+ Reply to Thread
Results 1 to 2 of 2

Tool or code to copy VBA code to OneNote or Word while preserving VBA formatting

Hybrid View

  1. #1
    Registered User
    Join Date
    11-07-2012
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Office 365
    Posts
    71

    Question Tool or code to copy VBA code to OneNote or Word while preserving VBA formatting

    So this is a little out the sideline, but:

    Whenever I do some code in VBA, I have to document this, either to myself in OneNote or in reports in Word. However, it seems impossible to copy VBA code from the editor to anything else and preserve the formatting.

    Basically I end up with this:
    'event handler for the run button 
    Private  Sub  btnRun_Click()
    Dim  i As  Integer 
    'loops through the cells in row 2 
    For  i = 1 To  6
        'checks if the wrap property is on 
        If  Range(Cells(2, i), Cells(2, i)).WrapText = True Then  
            'colors the cell green 
            Range(Cells(1, i), Cells(1, i)).Interior.Color = 3394611 
        Else  
            'removes any previous color assigned to the cell 
            Range(Cells(1, i), Cells(1, i)).Interior.Color = xlNone 
        End If  
    Next  i
    End  Sub
    While I would really like as presented here with colours and indents (mostly the colours).

    Are there any way to do this, or and online tool I simply cannot find? It makes reading the code in the future so much easier and elegant in reports.


    I hope you can help,


    GregersDK

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Tool or code to copy VBA code to OneNote or Word while preserving VBA formatting

    Hi gregersdk,

    I like to use Notepad++ (free using the GNU General Public License). See https://notepad-plus-plus.org/

    It is not automatically configured for .bas files (exported from VBA).

    To configure for .bas files (colors):
    a. Settings > Style Configurator > VB /VBS (as language)
    b. Add bas as User Extension > Save and Close
    c. Close all .bas files in NotePad++
    d. Close NotePad++
    e. Any new files opened in NotePadd++ should have colors

    Lewis

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 10-30-2014, 01:49 AM
  2. Replies: 7
    Last Post: 04-04-2014, 11:32 AM
  3. code to copy Excel to Word
    By Dennisli2000 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 09-24-2012, 03:05 PM
  4. Copy Picture and Preserving Formatting
    By lemerson in forum Excel General
    Replies: 0
    Last Post: 09-25-2007, 02:36 PM
  5. [SOLVED] Conditionally Formatting/Code Only One Word in a Formula
    By kdlilly in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-10-2006, 11:40 AM
  6. Tool / Code to copy and paste only the conditional formatting rules
    By Andibevan in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-09-2006, 07:04 AM
  7. Copy Data Via Code Word?
    By travelersway in forum Excel - New Users/Basics
    Replies: 0
    Last Post: 03-23-2005, 01:37 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1