Visual Basic, .NET, ASP, VBScript
 

   
   
     

Форум - VBA

Страница: 1 |

 

  Вопрос: Отвязать форму от Excel после выполнения Добавлено: 28.10.09 12:28  

Автор вопроса:  Jaguar7
Форма написанная в VBA вызывает Excel из шаблона создает файл и заполняет его значениями из базы по параметрам, задаваемым в самой форме юзером. А теперь проблема-после закрытия юзером полученного файла и самого Excel, в системе остается подвешенный процесс Excel, который мешает повторному запуску процедуры из формы, как закрыть связь формы и Excel без выгрузки формы?

Ответить

  Ответы Всего ответов: 7  

Номер ответа: 1
Автор ответа:
 GDK



Вопросов: 13
Ответов: 348
 Профиль | | #1 Добавлено: 28.10.09 15:14
Код неплохо было бы глянуть. И непонятно, форма что, должна остаться после того как юзер закроет ексель?

Ответить

Номер ответа: 2
Автор ответа:
 Дмитрий Юпатов



Вопросов: 4
Ответов: 457
 Web-сайт: cargomaster.at.ua/
 Профиль | | #2
Добавлено: 28.10.09 16:15
проблема-после закрытия юзером полученного файла и самого Excel, в системе остается подвешенный процесс Excel

Точно VBA? Больше похоже на ситуацию, когда к проекту на VB подключен Excel в качестве сервера автоматизации.
Тогда делай присваивание Nothing переменной - объекту Excel. А при дальнейшей необходимости создавай новый объект типа Microsoft.Office......Excel.Application
Или пробуй зацепить существующий...

Ответить

Номер ответа: 3
Автор ответа:
 Jaguar7



Вопросов: 2
Ответов: 5
 Профиль | | #3 Добавлено: 28.10.09 17:08
форма должна остаться для повторного запуска процедуры

Ответить

Номер ответа: 4
Автор ответа:
 Дмитрий Юпатов



Вопросов: 4
Ответов: 457
 Web-сайт: cargomaster.at.ua/
 Профиль | | #4
Добавлено: 28.10.09 17:11
проблема-после закрытия юзером полученного файла и самого Excel

Если это VBA, то при закрытии Excel форма тоже закроется полюбому. И процесса висящего в списке процессов не будет. Как не крути... Код выложи

Ответить

Номер ответа: 5
Автор ответа:
 Jaguar7



Вопросов: 2
Ответов: 5
 Профиль | | #5 Добавлено: 02.11.09 16:42
Private Sub File1_Click()
FileName = File1.FileName
        ;Dim Today As String
        ;Dim t As String
        t = Time
        Today = Format(t, "hh/mm/ss";)
        'удаление файлов временного баланса
        ;Dim FSO As New FileSystemObject, fil As File, fil1 As File
        On Error Resume Next
        FSO.DeleteFile ("c:\nodes\Temp*.xls";)
        On Error GoTo 0
        Set fil = FSO.GetFile("c:\nodes\" & FileName & "";)
        fil.Copy ("c:\nodes\Temp" & Today & "" & FileName & "";)
        'открываем файл для сканирования типа рапорта
        Set wbBook = xlApp.Workbooks.Open("c:\nodes\Temp" & Today & "" & FileName & "";)
        'адрес последней строки со значениями
        IRow = Cells.Find(What:="*", LookIn:=xlValues, SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
        'адрес последнего столбца со значениями
        iClm = Cells.Find(What:="*", LookIn:=xlValues, SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column
        
                      'начинаем сканирование диапазона для поиска имен тегов
                      For Co = 1 To iClm
                          For Ro = 1 To IRow
                              Ind = Cells(Ro, Co).Value
                              'ищем спецсимвол #
                              ;Dim Sim As String
                              Sim = Left(Ind, 1)
                              If Sim = "#" Then
                                   
                                           'откидываем служебный символ #
                                           ;Dim Ots As String
                                           Ots = Mid(Ind, 2)
                                                                                                                                
                                           'находим номер позиции знака ":"
                                           raz = InStr(1, Ots, ":";)
                                        
                                           'если двоеточия нет сразу идем на другой цикл
                                           If raz > 0 Then
                                               
                                               NodeName = Mid(Ots, 1, raz - 1)
                                               NodeDate = Mid(Ots, raz + 1)
                                               NodeDateS = Mid(Ots, raz + 1)
                                                   
                                                   'а вдруг это задание типа рапорта
                                                   ;Dim TypR As String
                                                   ;Dim TypRS As Integer
                                                   
                                                   If NodeName = "TYPE_REPORT" Then
                                                   TypR = NodeDateS
                                                   TypRS = TypR
                                                        Select Case TypR
                                                                Case 0
                                                                    Command1.Enabled = True
                                                                    GoTo RND:
                                                                Case 1
                                                                    Command1.Enabled = True
                                                                    GoTo RND:
                                                                Case 2
                                                                    Command1.Enabled = True
                                                                    GoTo RND:
                                                                Case 3
                                                                    Command1.Enabled = True
                                                                    GoTo RND:
                                                                Case 4
                                                                    Command1.Enabled = True
                                                                    GoTo RND:
                                                                Case 5
                                                                    Command1.Enabled = True
                                                                    GoTo RND:
                                                                Case 6
                                                                    Command1.Enabled = True
                                                                    GoTo RND:
                                                                Case 7
                                                                    Command1.Enabled = True
                                                                    GoTo RND:
                                                                Case 8
                                                                        List4.Enabled = True
                                                                        List3.Enabled = True
                                                                        List2.Enabled = True
                                                                        List1.Enabled = True
                                                                        GoTo RND:
                                                                Case 9
                                                                        List3.Enabled = True
                                                                        List2.Enabled = True
                                                                        List1.Enabled = True
                                                                        GoTo RND:
                                                                Case 10
                                                                        List2.Enabled = True
                                                                        List1.Enabled = True
                                                                        GoTo RND:
                                                                Case 11
                                                                        
                                                                        List2.Enabled = True
                                                                        GoTo RND:
                                                        End Select
                                                    End If
                                           End If
                            End If
                      Next
        Next
RND:
wbBook.Close ("c:\nodes\Temp" & Today & "" & FileName & "";)
        Set wbBook = Nothing
        On Error Resume Next
        FSO.DeleteFile ("c:\nodes\Temp" & Today & "" & FileName & "";)
        On Error GoTo 0
End Sub

Ответить

Номер ответа: 6
Автор ответа:
 Jaguar7



Вопросов: 2
Ответов: 5
 Профиль | | #6 Добавлено: 02.11.09 16:43
Private Sub File1_Click()
FileName = File1.FileName
        ;Dim Today As String
        ;Dim t As String
        t = Time
        Today = Format(t, "hh/mm/ss";)
        'удаление файлов временного баланса
        ;Dim FSO As New FileSystemObject, fil As File, fil1 As File
        On Error Resume Next
        FSO.DeleteFile ("c:\nodes\Temp*.xls";)
        On Error GoTo 0
        Set fil = FSO.GetFile("c:\nodes\" & FileName & "";)
        fil.Copy ("c:\nodes\Temp" & Today & "" & FileName & "";)
        'открываем файл для сканирования типа рапорта
        Set wbBook = xlApp.Workbooks.Open("c:\nodes\Temp" & Today & "" & FileName & "";)
        'адрес последней строки со значениями
        IRow = Cells.Find(What:="*", LookIn:=xlValues, SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
        'адрес последнего столбца со значениями
        iClm = Cells.Find(What:="*", LookIn:=xlValues, SearchDirection:=xlPrevious, SearchOrder:=xlByColumns).Column
        
                      'начинаем сканирование диапазона для поиска имен тегов
                      For Co = 1 To iClm
                          For Ro = 1 To IRow
                              Ind = Cells(Ro, Co).Value
                              'ищем спецсимвол #
                              ;Dim Sim As String
                              Sim = Left(Ind, 1)
                              If Sim = "#" Then
                                   
                                           'откидываем служебный символ #
                                           ;Dim Ots As String
                                           Ots = Mid(Ind, 2)
                                                                                                                                
                                           'находим номер позиции знака ":"
                                           raz = InStr(1, Ots, ":";)
                                        
                                           'если двоеточия нет сразу идем на другой цикл
                                           If raz > 0 Then
                                               
                                               NodeName = Mid(Ots, 1, raz - 1)
                                               NodeDate = Mid(Ots, raz + 1)
                                               NodeDateS = Mid(Ots, raz + 1)
                                                   
                                                   'а вдруг это задание типа рапорта
                                                   ;Dim TypR As String
                                                   ;Dim TypRS As Integer
                                                   
                                                   If NodeName = "TYPE_REPORT" Then
                                                   TypR = NodeDateS
                                                   TypRS = TypR
                                                        Select Case TypR
                                                                Case 0
                                                                    Command1.Enabled = True
                                                                    GoTo RND:
                                                                Case 1
                                                                    Command1.Enabled = True
                                                                    GoTo RND:
                                                                Case 2
                                                                    Command1.Enabled = True
                                                                    GoTo RND:
                                                                Case 3
                                                                    Command1.Enabled = True
                                                                    GoTo RND:
                                                                Case 4
                                                                    Command1.Enabled = True
                                                                    GoTo RND:
                                                                Case 5
                                                                    Command1.Enabled = True
                                                                    GoTo RND:
                                                                Case 6
                                                                    Command1.Enabled = True
                                                                    GoTo RND:
                                                                Case 7
                                                                    Command1.Enabled = True
                                                                    GoTo RND:
                                                                Case 8
                                                                        List4.Enabled = True
                                                                        List3.Enabled = True
                                                                        List2.Enabled = True
                                                                        List1.Enabled = True
                                                                        GoTo RND:
                                                                Case 9
                                                                        List3.Enabled = True
                                                                        List2.Enabled = True
                                                                        List1.Enabled = True
                                                                        GoTo RND:
                                                                Case 10
                                                                        List2.Enabled = True
                                                                        List1.Enabled = True
                                                                        GoTo RND:
                                                                Case 11
                                                                        
                                                                        List2.Enabled = True
                                                                        GoTo RND:
                                                        End Select
                                                    End If
                                           End If
                            End If
                      Next
        Next
RND:
wbBook.Close ("c:\nodes\Temp" & Today & "" & FileName & "";)
        Set wbBook = Nothing
        On Error Resume Next
        FSO.DeleteFile ("c:\nodes\Temp" & Today & "" & FileName & "";)
        On Error GoTo 0
End Sub

Ответить

Номер ответа: 7
Автор ответа:
 Jaguar7



Вопросов: 2
Ответов: 5
 Профиль | | #7 Добавлено: 02.11.09 16:44
подвис форум задвоилось сообщение, а убрать не знаю как:-(

Ответить

Страница: 1 |

Поиск по форуму



© Copyright 2002-2011 VBNet.RU | Пишите нам