PHANI KISHOREKOTTAPALLI,
An approach that I've used and which has worked very well, is to create a tab-delimited text file with a
VB program, and then when it's all done, give the User of opening the tab-delimited file in Notepad or Excel.
Here's the code under the 2 command buttons:
(a) For bring Text file into Excel (name of file stored in MyFinalPathFile variable):
' ************************************************** **************
' Import Tab-Delimited Output File into Excel
' ************************************************** **************
Private Sub cmdImportToExcel_Click()
' ************************************************** *****************
Dim ExcelApp As Object
On Error GoTo APPLICATION_CREATE ' An error will cause us to initiate the Appl.
Set ExcelApp = GetObject(, "Excel.Application")
GoTo SKIP_APPLICATION_CREATE ' Of course if it's already there, then we'll use that
APPLICATION_CREATE:
Set ExcelApp = CreateObject("Excel.Application")
SKIP_APPLICATION_CREATE:
On Error GoTo BYE ' Back to our normal way of life
' ************************************************** *******************
Dim myArray()
For i = 1 To intColumns
ReDim Preserve myArray(i)
myArray(i) = Array(i, 2)
Next
' ************************************************** *******************
Application.StatusBar = ". . . . . . . . . . . . . . . IMPORTING INTO EXCEL !! . . "
ExcelApp.Workbooks.OpenText FileName:=MyFinalPathFile, _
Origin:=xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier _
:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, Semicolon:= _
False, Comma:=False, Space:=False, Other:=False, FieldInfo:=myArray()
ColumnString = "A:" & ConvertColumnNumberToLetter(intColumns)
ExcelApp.Columns(ColumnString).EntireColumn.AutoFi t
ExcelApp.Range("A1").Select
ExcelApp.Visible = True
Application.StatusBar = ""
BYE:
End Sub
(b) For bringing file into NotePad:
Private Sub cmdViewOutputWithNotepad_Click()
Shell "Notepad.exe" & " " & MyFinalPathFile, vbMaximizedFocus
End Sub
For more info recommend
http://www.vba-programmer.com
CarlR