Изменения в теле программы не сохраняются, когда ActiveWorkbook.Close происходит - PullRequest
0 голосов
/ 12 марта 2019

У меня есть программа VBA, которая открывает файл .txt и выполняет поиск определенных строк / столбцов, выделяет эти строки / столбцы, а затем выполняет ActiveWorkbook.SaveAs.Проблема в том, что изменения не сохраняются, когда я получаю «ActiveWorkbook.Close SaveChanges: = True» Заранее спасибо Скотт

Option Explicit

Sub Import_txt()

    Dim i As Long
    Dim x As Long
    Dim y As Long
    Dim z As Long

' Import_txt Macro
'
'
    ChDir "C:\Users\parsons_s\Desktop\Verity II\G5_KLARF"
    Workbooks.OpenText Filename:= _
        "C:\Users\parsons_s\Desktop\Verity II\G5_KLARF\G5_KLARF.txt", Origin:=437, _
        StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
        ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, Comma:=False, _
        Space:=True, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3 _
        , 1), Array(4, 1)), TrailingMinusNumbers:=True


      'Find_txt Macro
    Cells.Find(What:="SampleTestPlan", After:=ActiveCell, LookIn:=xlFormulas _
        , LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
        MatchCase:=False, SearchFormat:=False).Activate

        x = ActiveCell.Offset(0, 1)
        y = ActiveCell.Row + 1
        z = ActiveCell.Row + 16
        i = 0


       With ActiveSheet
       'Shade Field Actions Blue
        Do While i < x
        Cells(y + i, 2).Interior.ColorIndex = 37
        Cells(y + i, 3).Interior.ColorIndex = 37
        i = i + 1
        Loop
        Cells(z, 3).Interior.ColorIndex = 37
        Cells(z, 4).Interior.ColorIndex = 37
        End With


    ActiveWorkbook.SaveAs Filename:="C:\Users\parsons_s\Desktop\Verity II\G5_KLARF\G5_KLARF_Find_locations.xls"


    'ActiveWorkbook.Close SaveChanges:=True

    Windows("KLARF converter.xlsm").Activate
End Sub
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...