|
-
Jan 8th, 2007, 11:20 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Text to Excel
All code start somewhere.
http://www.vbforums.com/showthread.php?t=445786
And understanding DoEvents
http://www.vbforums.com/showthread.p...16#post2742816
This program will convert a text file to Excel format.
Please post any comments.
Alpha Micro: Alpha Basic, AS400 V5r2, EDI (Trusted Link/ Inovis.com),Access AS/400 via VB6, Qbasic for data conversions. A mix of Hardware too. ASCII Table , New Number to Words/66 digits , AS/400(v5r2) VB6 Viewer/Ask for code(ODBC) ^ What Is Transferring? , Check your Ports #Perfect Passwords , *Slide Bar Example , Logoff, Restart, Shut-Down PC *Keep Form On Top , Opaque Form ^ Create Objects at Run Time @ Check Key Caps Locks # GetTickCount(System Up Time) * Convert text to Excel & Collected Icons + Resize: Form/Text box ^ PC GateWay via Shell $ Drag & Drop Game ! PopUpMenu *Print File/no Open# Timer on Mult Forms ~ Splash & Mult Forms & Lots of Comments + Random/Timer/Guess * Dec >Hex >Oct >Bin % Get MAC (NIC) < saving to Registry > Wookiee Cookies \ BackUpDisk / World Conection SpeedTest $ Glossary Commonly Used Terms # phonetic list @ Detailed Computer Scan
When posting Code, Use tags.. [CODE] *Your Code* [/CODE]
-
Jan 8th, 2007, 12:31 PM
#2
Re: Text to Excel
this can also be done through the Excel object itself:
VB Code:
Private Sub Command1_Click()
DelimitedTXTtoXLS "C:\test\test.txt", "~"
End Sub
Private Sub DelimitedTXTtoXLS(ByVal sFile As String, ByVal sDelim As String)
Dim oApp As Object 'Excel.Application
Set oApp = CreateObject("Excel.Application") 'New Excel.Application
oApp.Workbooks.OpenText FileName:=sFile, OtherChar:=sDelim, Origin:=3, DataType:=1, Other:=True
With oApp.Workbooks(1)
.SaveAs FileName:=Left$(sFile, InStrRev(sFile, ".")) & "xls", FileFormat:=-4143
.Saved = True
.Close
End With
oApp.Quit
Set oApp = Nothing
End Sub
code modified from this FAQ
Last edited by bushmobile; Jan 8th, 2007 at 12:36 PM.
-
Jan 8th, 2007, 12:36 PM
#3
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 8th, 2007, 01:41 PM
#4
Thread Starter
Fanatic Member
Re: Text to Excel
I knew there was an easier way. I researched several books last year (before VBforums) and created some version of this solution. Also, not in this code, I need to check some fields values. When I poll tha data from the AS400 via SQL some fields are null, so I check them before converting. Thanx BushMobil, I will test, try, play with your example.
-
Jan 8th, 2007, 01:45 PM
#5
Thread Starter
Fanatic Member
Re: Text to Excel
Rob, your code and Bush is the same. I need to check some values of some fields and I need to change some width of some cells, Excel does not like Nulls.
And format some colums. Thanks again
-
Jan 8th, 2007, 01:50 PM
#6
Re: Text to Excel
I posted mine first 
Are these new issues you need to do as in a new thread?
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 8th, 2007, 02:10 PM
#7
Thread Starter
Fanatic Member
Re: Text to Excel
Sorry, I was on the phone and I clicked after I finished some other work.
I aaaaaaaaaaaammmmmmmm sorry....hay, we having fun yet?
As for the issues....I'm fine. The code works, I can alter column format, check values..all good
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|