|
|
Регистрация Восстановить пароль |
Регистрация | Задать вопрос |
Заплачу за решение |
Новые сообщения |
Сообщения за день |
Расширенный поиск |
Правила |
Всё прочитано |
|
Опции темы | Поиск в этой теме |
03.07.2009, 19:27 | #1 |
Форумчанин
Регистрация: 19.06.2009
Сообщений: 163
|
Как создать из excel файл txt?
Нужно макросом создать файл test.txt с относительным путем, т.е. там же, где лежит и сам файл excel. И сохранить внутри test.txt текст, например: "бла-бла-бла текст из ячейки A1 бла-бла-бла текст из ячейки A2".
|
04.07.2009, 02:28 | #2 |
Участник клуба
Регистрация: 29.12.2008
Сообщений: 1,598
|
pute = ThisWorkbook.Path
transkr = Cells(1, 1) Open pute & "\text.txt" For Append As #1 'если файла нет, то 'создаётся новый файл, если файл существует, то значение ячейки А1 'записывается в конец документа. Print #1, Format$(transkr) Close #1 |
05.07.2009, 01:28 | #3 | |
Форумчанин
Регистрация: 25.08.2008
Сообщений: 159
|
Цитата из справки самого Excel
Цитата:
|
|
05.07.2009, 13:58 | #4 |
Форумчанин
Регистрация: 19.06.2009
Сообщений: 163
|
Спасибо большое. Только вот у меня не получается всавить сразу два вида тескта: "Мой текст" и Cells(1, 1). Как правильно написать эти вставки после transkr =, чтобы вставлялось одной строкой и в итоге получилось бы: "Мой текст Cells(1, 1)"?
Последний раз редактировалось ru3000; 05.07.2009 в 14:02. |
05.07.2009, 14:05 | #5 |
Форумчанин
Регистрация: 19.06.2009
Сообщений: 163
|
Все, сам нашел!
transkr = "Мой текст" & Cells(1, 1) |
20.05.2016, 10:33 | #6 |
Новичок
Джуниор
Регистрация: 20.05.2016
Сообщений: 1
|
Друзья,изменил вышеприведенный макрос для создания файла куда будут присаться значения из первой ячейки,второй ,третьей и четвертой (первый столбец).Все работает как надо,но проблема в том,что теоретически ячеек с данными в первом столбце может быть сотня,как его видоизменить макрос дабы они брал все заполненые ячейки первого столбца?
Sub Macro() Dim path As String Dim ext As String ext = "txt" path = ThisWorkbook.path Kill path & "\text.txt" pute = ThisWorkbook.path transfer1 = Cells(1, 1) Open pute & "\text.txt" For Append As #1Print #1, Format(transfer1) Close #1 transfer1 = Cells(2, 1) Open pute & "\text.txt" For Append As #2 Print #2, Format(transfer1) Close #2 transfer1 = Cells(3, 1) Open pute & "\text.txt" For Append As #3 Print #3, Format(transfer1) Close #3 transfer1 = Cells(4, 1) Open pute & "\text.txt" For Append As #4 Print #4, Format(transfer1) Close #4 |
Похожие темы | ||||
Тема | Автор | Раздел | Ответов | Последнее сообщение |
как открыть файл.txt | Sergeu | Общие вопросы Delphi | 1 | 25.09.2008 13:24 |
Как создать новый файл Word из макроса Excel? | Dorvir | Microsoft Office Excel | 12 | 08.07.2008 16:50 |
Как создать txt файл | Titan123 | Общие вопросы Delphi | 7 | 29.06.2008 16:56 |
как сохранить строчки в TXT файл | Ярослав | Помощь студентам | 2 | 17.05.2008 18:43 |
Как прочесть txt файл www.site.ru/info.txt | BR17UY | Работа с сетью в Delphi | 1 | 16.04.2007 13:01 |