Компьютерный форум OSzone.net  

Компьютерный форум OSzone.net (http://forum.oszone.net/index.php)
-   Скриптовые языки администрирования Windows (http://forum.oszone.net/forumdisplay.php?f=102)
-   -   исправить макрос excel (http://forum.oszone.net/showthread.php?t=265867)

oleg-sm 09-08-2013 16:25 2199092

исправить макрос excel
 
доброго времени суток!
есть макрос, он выполняет сбор данных и записывает в файл для дальнейшей обработки. работает без проблем, но мне нужно внести коррективу:
Код:

Attribute VB_Name = "Module1"
Sub Пленка()
  Dim f: Dim filesys
  Dim N As Byte: N = 1
  Dim S As Worksheet
  Set S = ActiveWorkbook.ActiveSheet
  Set filesys = CreateObject("Scripting.FileSystemObject")
  Text1 = "Mouse: x:240 y:426 butt:Left" ' Ширина
  Text2 = "Mouse: x:313 y:426 butt:Left" ' Высота
  Text3 = "Mouse: x:116 y:426 butt:Left" ' Количество
  Text4 = "Mouse: x:556 y:426 butt:Left" ' Клиент
  Text5 = "Mouse: x:355 y:468 butt:Left" ' Пленка
  Text6 = "Mouse: x:165 y:489 butt:Left" ' тыц
  Text7 = "Mouse: x:60 y:545 butt:Left" ' Сохранение
  i = 1
  While S.Cells(i, 1) <> ""
    Set f = filesys.CreateTextFile("C:\Documents and Settings\oleg\desktop\Prog" & N & ".gpr")
    Do
        f.WriteLine Text1
        f.WriteLine Text1
        f.WriteLine "Key:" & S.Cells(i, 2)
        f.WriteLine Text2
        f.WriteLine Text2
        f.WriteLine "Key:" & S.Cells(i, 3)
        f.WriteLine Text3
        f.WriteLine Text3
        f.WriteLine "Key:" & S.Cells(i, 4)
        f.WriteLine Text4
        f.WriteLine Text4
        f.WriteLine "Key:" & S.Cells(i, 5)
        f.WriteLine Text5
        f.WriteLine Text5
        f.WriteLine "Key:" & S.Cells(i, 6)
        f.WriteLine Text6
        'f.WriteLine "Mouse: x:165 y:489 butt:Left"
      f.WriteLine Text7
        'f.WriteLine "Mouse: x:653 y:562 butt:Left"
      f.WriteLine "Delay:00:00:01"
        i = i + 1
        Loop While S.Cells(i, 1) = S.Cells(i + 1, 1)
        If S.Cells(i, 1) = S.Cells(i - 1, 1) Then
            f.WriteLine Text1
            f.WriteLine Text1
            f.WriteLine "Key:" & S.Cells(i, 2)
            f.WriteLine Text2
            f.WriteLine Text2
            f.WriteLine "Key:" & S.Cells(i, 3)
            f.WriteLine Text3
            f.WriteLine Text3
            f.WriteLine "Key:" & S.Cells(i, 4)
            f.WriteLine Text4
            f.WriteLine Text4
            f.WriteLine "Key:" & S.Cells(i, 5)
            f.WriteLine Text5
            f.WriteLine Text5
            f.WriteLine "Key:" & S.Cells(i, 6)
            f.WriteLine Text6
            'f.WriteLine "Mouse: x:165 y:489 butt:Left"
          f.WriteLine Text7
            'f.WriteLine "Mouse: x:653 y:562 butt:Left"
          f.WriteLine "Delay:00:00:01"
        End If
    f.WriteLine "Delay:00:00:01"
    f.Close
    i = i + 1: N = N + 1
  Wend
End Sub

задача следующая - я дописал Text6 и теперь он выполняется циклом, а мне нужно, чтобы он выполнился всего один раз, т.е. его нужно бы вытянуть из цикла и записать отдельно, как это сделать? заранее благодарен!

Iska 09-08-2013 19:01 2199173

Цитата:

Цитата oleg-sm
я дописал Text6 и теперь он выполняется циклом, а мне нужно, чтобы он выполнился всего один раз, т.е. его нужно бы вытянуть из цикла и записать отдельно »

Ну, так и вынесете эти строки за пределы цикла.

Цитата:

Цитата oleg-sm
как это сделать? »

Вырезать/вставить ;).


Время: 00:01.

Время: 00:01.
© OSzone.net 2001-