Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


chr() code for Alt-Enter

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,61044
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> chr() code for Alt-Enter
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 chr() code for Alt-Enter - 6/4/2008 2:09:41 PM   
  thorwath


Posts: 42
Score: 0
Joined: 12/6/2006
From: Grand Rapids, MI
Status: offline
In MS Excel if you interactively type some text into a cell and then press Alt-Enter (both keys together) you get a line break in the cell and can start typing a 2nd line in the cell. So within a single cell it looks like:

line foo
line bar
etc.

I currently am converting a file of information into a comma delimited output file that I then want to open in Excel. One of the fields I am writing to this output file needs to embed the "magic" chr() code between the "line foo" and "line bar" strings above so that Excel will place both strings in the same cell with the line break in between the two strings. So my output should logically look like:

"... , line foo<line break char> line bar <line break char> etc... , ..."

I have searched the Internet and WSH online help but can't figure out how to do this.

Is it possible using a chr(num) value to produce the desired <line break char> above?

-Thanks, Terry Horwath

P.S. I have tried all the easy suspects: chr(9) thru chr(13). Some of these produce a special char "box" in the Excel field, while others force the 2nd, 3rd, etc. string patterns into a new cell in the first column.

< Message edited by thorwath -- 6/4/2008 2:12:55 PM >
 
 
Post #: 1
 
 RE: chr() code for Alt-Enter - 6/4/2008 2:31:05 PM   
  dm_4ever


Posts: 2664
Score: 46
Joined: 6/29/2006
From: Orange County, California
Status: offline
Recording a macro shows it is Chr(10)....you may not be able to do this with a CSV file....why not write it straight to the XLS file.

_____________________________

dm_4ever

My philosophy: K.I.S.S - Keep It Simple Stupid
Read Me: http://www.visualbasicscript.com/m_24727/tm.htm
Frequently Asked Stuff: http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to thorwath)
 
 
Post #: 2
 
 RE: chr() code for Alt-Enter - 6/5/2008 9:36:55 PM   
  thorwath


Posts: 42
Score: 0
Joined: 12/6/2006
From: Grand Rapids, MI
Status: offline
That suggestion was the kick in the pants I needed! I got fixated on doing this with a comma delimited text file (as that is the common "currency" at this company where development works on AS400, Windows, Linux and Unix platforms--but I really only need this to work on the Windows platform).

I got it too work with only a few lines of code:

      
But I find the MS help file, VBAXL10.CHM, ponderous and difficult to work with. Is there a forum similar to this one, that anyone can recommend that is focused on MS Office Automation?

(in reply to dm_4ever)
 
 
Post #: 3
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> chr() code for Alt-Enter Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts