+ Reply to Thread
Results 1 to 13 of 13

replace : with new line in VBA editor

  1. #1
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    replace : with new line in VBA editor

    Hi all,
    I have VBA code to create a dxf file which has 1500 line compressed with : into about 100 lines

    Please Login or Register  to view this content.
    I would like to remove all the next line : and replace them with a new line in the VBA editor code so the code is easier to read and work with


    Please Login or Register  to view this content.

    Alt + 010 in the number pad doesnt work with the VBA editor find and replace tool

    any ideas on how the code could be defraged?
    Last edited by pike; 04-15-2011 at 05:49 AM.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  2. #2
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: replace : with new line in VBA editor

    Personally I would select all & copy it to the clipboard.

    Then use something like Notepad++ to do the search and replace (it will easily be able to replace ':' with the newline character.
    Then when it is formated correctly copy it back into VBA to replace what you currently have.
    If you find the response helpful please click the scales in the blue bar above and rate it
    If you don't like the response, don't bother with the scales, they are not for you

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,461

    Re: replace : with new line in VBA editor

    I'd be inclined to take the simplistic approach.

    Copy it into Word, do the global replace (":" by "^p") and copy it back

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  4. #4
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: replace : with new line in VBA editor

    I'd probably do that too, but if you want code then run this with your module active (and this code in a different module!):
    Please Login or Register  to view this content.
    Last edited by romperstomper; 04-15-2011 at 05:39 AM. Reason: add space after colon
    Remember what the dormouse said
    Feed your head

  5. #5
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: replace : with new line in VBA editor

    Hi Phil_V,
    I exported the bas file and opened in Note pad but is the same with alt + 010
    Hi TMShucks,
    To easy word is the way to go
    thanks
    It is amazing The file unfragaed and cleaned code added 1,500KB to the file.. not that file size is a problem 2,500kb

  6. #6
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: replace : with new line in VBA editor

    romperstomper
    Thats a keeper
    thanks

  7. #7
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: replace : with new line in VBA editor

    I've just changed the colon to a colon followed by a space - probably safer.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,461

    Re: replace : with new line in VBA editor

    @Pike: you're welcome - makes a change for me to be able to help you ;-)

  9. #9
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: replace : with new line in VBA editor

    your switched on
    yes, the code checks for "C:\ TEMP" folder and if it dosent exist creates it.
    Then saves the dxf file to the "C:\ TEMP" folder to be accessed by cad.
    Last edited by pike; 04-15-2011 at 05:50 AM.

  10. #10
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,461

    Re: replace : with new line in VBA editor

    @romperstomper: just messing about with your code and I get an error:

    Dim cm As CodeModule

    User defined type not defined.

    What reference(s) do I need to add?

    Did you intend to post a new version?

    Thanks

  11. #11
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: replace : with new line in VBA editor

    It needs a reference to the "Microsoft Visual Basic for Applications Extensibility 5.3" library as written, though you could just declare as Object.

  12. #12
    Forum Contributor
    Join Date
    02-23-2006
    Location
    Near London, England
    MS-Off Ver
    Office 2003
    Posts
    770

    Re: replace : with new line in VBA editor

    Quote Originally Posted by pike View Post
    Hi Phil_V,
    I exported the bas file and opened in Note pad but is the same with alt + 010
    I know you've now solved this, but for your reference, in Notepad++ you wouldn't use Alt + 010.

    In the search and replace box you would search for ": "
    In the replace with box you would have "\n"
    The search mode would be set to 'Extended' to support the above formatting.


  13. #13
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: replace : with new line in VBA editor

    Thanks Phil & TMShucks for the help, solutions and new knowledge.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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