Oppure

Loading
24/01/09 14:01
moet
Ciao a tutti !

Ho creato un programma che compila un file excel gia esistente e me ne dovrebbe salvare una copia nuova con il nome del cliente in una sotto cartella dal nome schede riparazione.

in realta' al momento del salvataggio si apre la cartella dove risiede il file gia esistente( e non nella sottocartella schede riparazione) ed invece di uscirmi il nome del cliente mi esce "copia di riparazione.xls"

probabilmente devo cambiare le istruzioni di salvataggio ma chiedo aiuto ! :)

vorrei lasciare il file "base" riparazione.xls e il nuovo nella sottocartella.

Grazie


Dim oldname As String
Dim newname As String

Dim XLS As New Excel.Application
    With XLS
        .Workbooks.Open App.Path & "\riparazione.xls"

'istruzioni

        .Visible = False 
        

        
        
        

        .SaveWorkspace App.Path & "\SCHEDE DI RIPARAZIONE\" & txtcliente.Text & ".xls"
         MsgBox "FILE CLIENTE: " & txtcliente & " SALVATO CON SUCCESSO ", , "GARAGE MARCO"

Ultima modifica effettuata da moet 24/01/09 14:02
aaa
24/01/09 17:08
GrG
mm...nn ho molta dimestichezza con excel...comunque se ho capito bene tu prima di modificare un file excel lo vorresti salvare in una cartella...cioè fare una sorta di copia di backup, giusto?

Se si prova ad usare:
FileCopy app.path & "\riparazione.xls", app.path & "\tuaCartella\nuovonome.xls"
Ultima modifica effettuata da GrG 24/01/09 17:09
aaa
24/01/09 20:52
tippolo
Postato originariamente da moet:

Ciao a tutti !

Ho creato un programma che compila un file excel gia esistente e me ne dovrebbe salvare una copia nuova con il nome del cliente in una sotto cartella dal nome schede riparazione.



Ciao ho sottomano una sub di un progetto che ho fatto un po di tempo fa
Private Sub mnuSalva_Click()
'salva il file col cognome e nome precedentemente inseriti
cdgSalva.ShowSave
    If cdgSalva.FileName <> "" Then
          FileExcel.SaveAs cdgSalva.FileName & " " & ExcelObj.Label1
    End If
End Sub

cdgSalva = commondialog
in label1 c'è il nominativo
Vedi un pò di modificarla in base alle tue esigenze. Cartella, sottocartella...
Ultima modifica effettuata da tippolo 24/01/09 20:52
aaa
26/01/09 20:07
moet
Niente da fare non sono riuscito ne con il file copy ne con la common...

altre idee ?!?!? :) :rotfl:
aaa
26/01/09 20:20
P4p3r0g4
con open .. get.. close?
ma e` molto piu facile con il filecopy.
e se non funziona e` perche hai sbagliato qualcosa nel codice.
aaa
26/01/09 20:29
moet
Provo a postarlo!
aaa
26/01/09 20:33
GrG
che sistema operativo hai?
aaa
26/01/09 20:34
moet
lo posto tutto !!!

E' una scheda di riparazione di un meccanico.

Con dati cliente e la lista dei lavori eseguiti.


Private Sub Cmdsalva_Click()
Dim oldname As String
Dim newname As String

Dim XLS As New Excel.Application
    With XLS
        .Workbooks.Open App.Path & "\riparazione.xls"
        
        'oldname = App.Path & "\riparazione.xls"
        
        
        .Worksheets(1).Select
        
        .Range("C4").Select

        .ActiveCell.Value = txtcliente.Text
        
        .Range("C6").Select

        .ActiveCell.Value = txtindirizzo.Text
        
        .Range("B8").Select

        .ActiveCell.Value = txtcitta.Text
        
        .Range("F8").Select

        .ActiveCell.Value = txttelefono.Text   'Label5.Caption
        
        .Range("B10").Select

        .ActiveCell.Value = txtvettura.Text
        
        .Range("F10").Select

        .ActiveCell.Value = txtkm.Text
        
        .Range("B12").Select

        .ActiveCell.Value = txttarga.Text
        
        .Range("F12").Select

        .ActiveCell.Value = txtmotore.Text
        
        
        
        .Range("A16").Select
        .ActiveCell.Value = txtq1.Text
        .Range("B16").Select
        .ActiveCell.Value = txtd1.Text
        .Range("I16").Select
        .ActiveCell.Value = txteuro1.Text
        
        .Range("A17").Select
        .ActiveCell.Value = txtq2.Text
        .Range("B17").Select
        .ActiveCell.Value = txtd2.Text
        .Range("I17").Select
        .ActiveCell.Value = txteuro2.Text
        
        .Range("A18").Select
        .ActiveCell.Value = txtq3.Text
        .Range("B18").Select
        .ActiveCell.Value = txtd3.Text
        .Range("I18").Select
        .ActiveCell.Value = txteuro3.Text
        
        .Range("A19").Select
        .ActiveCell.Value = txtq4.Text
        .Range("B19").Select
        .ActiveCell.Value = txtd4.Text
        .Range("I19").Select
        .ActiveCell.Value = txteuro4.Text
        
        .Range("A20").Select
        .ActiveCell.Value = txtq5.Text
        .Range("B20").Select
        .ActiveCell.Value = txtd5.Text
        .Range("I20").Select
        .ActiveCell.Value = txteuro5.Text
        
        .Range("A21").Select
        .ActiveCell.Value = txtq6.Text
        .Range("B21").Select
        .ActiveCell.Value = txtd6.Text
        .Range("I21").Select
        .ActiveCell.Value = txteuro6.Text
        
        .Range("A22").Select
        .ActiveCell.Value = txtq7.Text
        .Range("B22").Select
        .ActiveCell.Value = txtd7.Text
        .Range("I22").Select
        .ActiveCell.Value = txteuro7.Text
        
        .Range("A23").Select
        .ActiveCell.Value = txtq8.Text
        .Range("B23").Select
        .ActiveCell.Value = txtd8.Text
        .Range("I23").Select
        .ActiveCell.Value = txteuro8.Text
        
        .Range("A24").Select
        .ActiveCell.Value = txtq9.Text
        .Range("B24").Select
        .ActiveCell.Value = txtd9.Text
        .Range("I24").Select
        .ActiveCell.Value = txteuro9.Text
        
        .Range("A25").Select
        .ActiveCell.Value = txtq10.Text
        .Range("B25").Select
        .ActiveCell.Value = txtd10.Text
        .Range("I25").Select
        .ActiveCell.Value = txteuro10.Text
        
        .Range("A26").Select
        .ActiveCell.Value = txtq11.Text
        .Range("B26").Select
        .ActiveCell.Value = txtd11.Text
        .Range("I26").Select
        .ActiveCell.Value = txteuro11.Text
        
        .Range("A27").Select
        .ActiveCell.Value = txtq12.Text
        .Range("B27").Select
        .ActiveCell.Value = txtd12.Text
        .Range("I27").Select
        .ActiveCell.Value = txteuro12.Text
        
        .Range("I36").Select
        .ActiveCell.Value = txtimponibile.Text
        .Range("I37").Select
        .ActiveCell.Value = txtiva.Text
        .Range("I38").Select
        .ActiveCell.Value = txttotale.Text
        
        
        .Visible = False 'true
        
         

        
        'newname = App.Path & "\SCHEDE DI RIPARAZIONE\" & txtcliente.Text & ".xls"

        .SaveWorkspace App.Path & "\SCHEDE DI RIPARAZIONE\" & txtcliente.Text & ".xls"
        
         MsgBox "FILE CLIENTE: " & txtcliente & " SALVATO CON SUCCESSO ", , "GARAGE MARCO"
    End With
'XLS.Workbooks(1).Close true
' mandalo in stampa
End Sub
aaa