Hi: I try to write in excel 2 textfiles in 2 sheets but only write the last
i think i missing something but i dont know, thanks for yuor help
Dim xl As Object
xl = CreateObject("Excel.Application")
xl.Visible = False
xl.Workbooks.Add()
xl.Workbooks.OpenText(Filename:="C:\Documents and Settings\User\Desktop\429\sheet1" & ".txt", Origin:=Excel.XlPlatform.xlMSDOS, StartRow:=1, _
DataType:=Excel.XlTextParsingType.xlFixedWidth, TextQualifier:=Excel.XlTextQualifier.xlTextQualifierNone, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=True, Comma:=False, Space:=False, Other:=False, _
FieldInfo:=New Object() {New Object() {0, 2}, New Object() {9, 9}, _
New Object() {11, 1}, New Object() {12, 9}, New Object() {14, 1}, New Object() {46, 1}, _
New Object() {56, 9}, New Object() {58, 5}, New Object() {64, 9}, New Object() {66, 1}, _
New Object() {74, 9}, New Object() {76, 1}, New Object() {82, 9}, New Object() {84, 1}, _
New Object() {89, 9}, New Object() {91, 5}, New Object() {97, 9}, New Object() {99, 5}, _
New Object() {105, 9}, New Object() {107, 5}, New Object() {113, 9}, New Object() {115, 1}, _
New Object() {116, 9}})
xl.workSheets("Sheet" & 1).Select()
xl.workSheets("Sheet" & 1).name = "cesar"
'xl.Workbooks.Add()
xl.Workbooks.OpenText(Filename:="C:\Documents and Settings\User\Desktop\429\sheet2" & ".txt", Origin:=Excel.XlPlatform.xlMSDOS, StartRow:=1, _
DataType:=Excel.XlTextParsingType.xlFixedWidth, TextQualifier:=Excel.XlTextQualifier.xlTextQualifierNone, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=True, Comma:=False, Space:=False, Other:=False, _
FieldInfo:=New Object() {New Object() {0, 2}, New Object() {9, 9}, _
New Object() {11, 1}, New Object() {12, 9}, New Object() {14, 1}, New Object() {46, 1}, _
New Object() {56, 9}, New Object() {58, 5}, New Object() {64, 9}, New Object() {66, 1}, _
New Object() {74, 9}, New Object() {76, 1}, New Object() {82, 9}, New Object() {84, 1}, _
New Object() {89, 9}, New Object() {91, 5}, New Object() {97, 9}, New Object() {99, 5}, _
New Object() {105, 9}, New Object() {107, 5}, New Object() {113, 9}, New Object() {115, 1}, _
New Object() {116, 9}})
xl.workSheets("Sheet" & 2).Select()
xl.workSheets("Sheet" & 2).name = "martinez"
xl.Worksheets(1).SaveAs("C:\Documents and Settings\User\Desktop\filetemp\bo" & ".xls", Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange)
xl.Quit()
xl = Nothing
End
i think i missing something but i dont know, thanks for yuor help
Dim xl As Object
xl = CreateObject("Excel.Application")
xl.Visible = False
xl.Workbooks.Add()
xl.Workbooks.OpenText(Filename:="C:\Documents and Settings\User\Desktop\429\sheet1" & ".txt", Origin:=Excel.XlPlatform.xlMSDOS, StartRow:=1, _
DataType:=Excel.XlTextParsingType.xlFixedWidth, TextQualifier:=Excel.XlTextQualifier.xlTextQualifierNone, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=True, Comma:=False, Space:=False, Other:=False, _
FieldInfo:=New Object() {New Object() {0, 2}, New Object() {9, 9}, _
New Object() {11, 1}, New Object() {12, 9}, New Object() {14, 1}, New Object() {46, 1}, _
New Object() {56, 9}, New Object() {58, 5}, New Object() {64, 9}, New Object() {66, 1}, _
New Object() {74, 9}, New Object() {76, 1}, New Object() {82, 9}, New Object() {84, 1}, _
New Object() {89, 9}, New Object() {91, 5}, New Object() {97, 9}, New Object() {99, 5}, _
New Object() {105, 9}, New Object() {107, 5}, New Object() {113, 9}, New Object() {115, 1}, _
New Object() {116, 9}})
xl.workSheets("Sheet" & 1).Select()
xl.workSheets("Sheet" & 1).name = "cesar"
'xl.Workbooks.Add()
xl.Workbooks.OpenText(Filename:="C:\Documents and Settings\User\Desktop\429\sheet2" & ".txt", Origin:=Excel.XlPlatform.xlMSDOS, StartRow:=1, _
DataType:=Excel.XlTextParsingType.xlFixedWidth, TextQualifier:=Excel.XlTextQualifier.xlTextQualifierNone, _
ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=True, Comma:=False, Space:=False, Other:=False, _
FieldInfo:=New Object() {New Object() {0, 2}, New Object() {9, 9}, _
New Object() {11, 1}, New Object() {12, 9}, New Object() {14, 1}, New Object() {46, 1}, _
New Object() {56, 9}, New Object() {58, 5}, New Object() {64, 9}, New Object() {66, 1}, _
New Object() {74, 9}, New Object() {76, 1}, New Object() {82, 9}, New Object() {84, 1}, _
New Object() {89, 9}, New Object() {91, 5}, New Object() {97, 9}, New Object() {99, 5}, _
New Object() {105, 9}, New Object() {107, 5}, New Object() {113, 9}, New Object() {115, 1}, _
New Object() {116, 9}})
xl.workSheets("Sheet" & 2).Select()
xl.workSheets("Sheet" & 2).name = "martinez"
xl.Worksheets(1).SaveAs("C:\Documents and Settings\User\Desktop\filetemp\bo" & ".xls", Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlNoChange)
xl.Quit()
xl = Nothing
End