Удаление столбца в нескольких файлах excel |
Function ryhsdryh() Dim strFile As String Dim xlApp As Excel.Application Dim xlBook As Excel.Workbook Dim xlSheet As Excel.Worksheet strFile = Dir("C:\тест\") Do Until strFile = "" If (Right(strFile, 3) = "xls") Or (Right(strFile, 4) = "xlsx") Then Set xlApp = CreateObject("Excel.Application") Set xlBook = xlApp.Workbooks.Open("C:\тест\" & strFile) Set xlSheet = xlBook.Worksheets(1) xlSheet.Activate With xlSheet Columns("B:B").Select Selection.Delete End With xlBook.Save xlBook.Close Set xlSheet = Nothing Set xlBook = Nothing Set xlApp = Nothing End If strFile = Dir Loop End FunctionУдаляется столбец только в первом перебираемом файле и всё. На втором вылетает ошибка, указывающая на строку с Columns("B:B").Select, типа Global Failed.
http://www.sql.ru/forum/1145620/udalenie-stolbca-v-neskolkih-faylah-excel
Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |