Oppure

Loading
31/01/08 21:59
moet
ciao a tutti !

ho creato un programma di gestione che apre, modifica manda in stampa diversi file di word, excel ecc che si trovano in locale.

ma il piu delle volte dopo averli aperti con shell da programma li chiudo normalmente con la X in alto a destra.

probabilmente questo comporta che il programma word, excel e chi per esso rimangono in esecuzione.

mi spiego meglio...

se dovessi riaprire da programma i vari file non me li riapre o me li fa vedere per pochi millisecondi e spariscono.

come posso ovviare al problema?

p.s. aprendo il task manager mi ritrovo in processi tantissimi winword ecc...



grazie
aaa
01/02/08 12:42
Security-007
Option Explicit
Dim FileExcel As Workbook

Private Sub Form_Load()
    If VerifyFile(App.Path & "\excelObj.xls") Then
        Set FileExcel = Excel.Workbooks.Open(App.Path & "\excelObj.xls")
    Else
        MsgBox "Impossibile eseguire il programma" & _
        vbCrLf & "Il file " & App.Path & "\excelObj.xls" & " non è stato trovato.", vbOKOnly
        End
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
 FileExcel.Close (True)
End Sub

Public Function VerifyFile(FileName As String)
On Error Resume Next
Open FileName For Input As #1
If Err Then
VerifyFile = False
Exit Function
End If
Close #1
VerifyFile = True
End Function
aaa
01/02/08 13:30
moet
no
Ultima modifica effettuata da moet 01/02/08 15:08
aaa
01/02/08 14:57
moet
petta petta...

il file excel io lo apro in locale... ti posto il codice cosi mi spiego meglio!

Dim XLS As New Excel.application
    With XLS
        .Workbooks.Open App.Path & "\DATECONSUMI.xls"
        .Worksheets(1).Select
        .Range("D3").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 14
        .ActiveCell.Value = ricorda & Txtnomebarca.Text
        .Range("D5").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 14
        .ActiveCell.Value = arrivo
        .Range("D7").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 14
        .ActiveCell.Value = partenza
        .Range("H5").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 14
        .ActiveCell.Value = txtoraarrivo.Text
        .Range("H7").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 14
        .ActiveCell.Value = txtorapartenza.Text
        .Range("J4").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 14
        .ActiveCell.Value = certificato
        .Range("K4").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 14
        .ActiveCell.Value = assicurazione
        .Range("M4").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 14
        .ActiveCell.Value = rr
        .Range("J7").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 14
        .ActiveCell.Value = fax
        .Range("L7").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 12
        .ActiveCell.Value = txtvaloreimbarcazione
        .Range("D11").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 10
        .ActiveCell.Value = txtbcolonnina.Text
        .Range("E13").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 14
        .ActiveCell.Value = belettrico
        .Range("E15").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 14
        .ActiveCell.Value = bidrico
        .Range("E17").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 14
        .ActiveCell.Value = btelefonico
        .Range("J13").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 12
        .ActiveCell.Value = txtbelettrico.Text
        .Range("J15").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 12
        .ActiveCell.Value = txtbidrico.Text
        .Range("J17").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 12
        .ActiveCell.Value = txtbtelefonico.Text
        .Range("D21").Select
        .ActiveCell.Font.Bold = True
        .ActiveCell.Font.Size = 12
        .ActiveCell.Value = alaggio
        
        
        
        
        
        .Visible = True
        Call azzera
    End With
    
   
   
    
End Sub
aaa
01/02/08 15:07
moet
quando li apro cosi:

ShellDocument App.Path & "\RR\Parking document's and request B_ING.doc"


praticamente mi si apre il documento word sul pc ( non su una text nel programma ).

io lo modifico tipo la data ecc e lo mando in stampa(utilizzo l' icona di word ).

lo chiudo( pulsantino in cima adestra con la X a sfondo rosso) senza salvarlo per una successiva riutilizzazione.

e torno al mio programma vb.

se dopo un po ho di nuovo bisogno di riaprire il file word e chiaramente utilizzo la stessa funzione

ShellDocument App.Path & "\RR\Parking document's and request B_ING.doc"


non mi si apre! perche è come se il mio programma vb lo visualizza gia aperto.

infatti andando sul task manager vedo gia in esecuzione word.

non è facile da spiegare, ma ringrazio in anticipo chi mi possa aiutare.
aaa
01/02/08 15:21
LuigiBiasi
ciao, se provi ad utilizzare questo codice non dovrebbe darti nessun problema,
Private Sub Command1_Click()
Dim c As Object
Set c = CreateObject("shell.application")
c.open "pathdelfile.doc"
End Sub


io ho testato questo e non ho avuto problemi(cioè il file si apre, si chiude e si riapre senza nessun problema anche effettuando modifiche, e senza chiudere mai l'applicazione di vb) quello che hai scritto tu non ho tempo adesso di testarlo, più tardi daro un occhiata.
ciao.
Ultima modifica effettuata da LuigiBiasi 01/02/08 15:23
aaa