Sauro ha scritto...
>Il concetto č chiaro, e ti ringrazio per il chiarimento,
>ma mi mancano le istruzioni per aprire il nuovo workbook
>anche perchč non sň a priori dove diavolo sia il file "Cartel1"
>se il programma gira su diversi PC (XP o W7)..
Analizza questo spezzone di codice che ho buttato giů a braccio
e vedi se ti puň in qualche modo aiutare:
Private Sub Form_Load()
Dim ExApp As Object
Dim ExWrk As Object
Dim ExSheet As Object
On Error Resume Next
Set ExApp = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
Debug.Print Err.Description
Err.Clear
Set ExApp = CreateObject("Excel.Application")
If Err.Number <> 0 Then
MsgBox "Error! " & Err.Description
exit sub
end if
End If
On Error GoTo 0
ExApp.Visible = True
Set ExWrk = ExApp.Workbooks.Add
If Dir(App.Path & "\Test.xls", vbNormal) = "Test.xls" Then Kill App.Path
& "\Test.xls"
ExWrk.SaveAs App.Path & "\Test.xls"
For Each ExSheet In ExWrk.Worksheets
Debug.Print ExSheet.Name
Next
Set ExSheet = ExWrk.Worksheets("Foglio1")
Set ExSheet = ExWrk.Worksheets(1)
ExSheet.Cells(5, 2).Value = "Pippo"
Debug.Print ExSheet.Cells(5, 2).Value
ExWrk.Save
ExWrk.Close
ExApp.Quit
Set ExApp = Nothing
Set ExWrk = Nothing
Set ExSheet = Nothing
End Sub