Condividi:        

[PPT] chiudere presentazione ed aprire file Excel

Vuoi potenziare i tuoi documenti Word? Non sai come si fa una macro in Excel? Devi creare una presentazione in PowerPoint?
Oppure sei passato a OpenOffice e non sei sicuro di come lavorare al meglio?

Moderatori: Anthony47, Flash30005

[PPT] chiudere presentazione ed aprire file Excel

Postdi BG66 » 18/02/18 06:39

Ciao a tutti,
Ho uno script nell'ultima slide che salva informazioni in file excel per poi chiuderlo.
Codice: Seleziona tutto
Sub SaveToExcel()    'ADDED
    Dim oXLApp As Object
    Dim oWb As Object
    Dim row As Long
    Dim strTitle As String
    Dim strdate As String


With ActivePresentation.Slides(1).Shapes("Title")
strTitle = .TextFrame.TextRange
If strTitle = "" Then strTitle = "Not Found"
End With
    strdate = Format(Date, "dd/mm/yyyy")
    Set oXLApp = CreateObject("Excel.Application")
    'On a Mac change \ to : in the following line
    Set oWb = oXLApp.Workbooks.Open(ActivePresentation.Path & "\" & "AvvioCorso.xlsm")
    If oWb.Worksheets(1).Range("A1") = "" Then
        oWb.Worksheets(1).Range("A1") = "Title"
        oWb.Worksheets(1).Range("B1") = "Date"
        oWb.Worksheets(1).Range("C1") = "Name"
        oWb.Worksheets(1).Range("D1") = "Number Correct"
        oWb.Worksheets(1).Range("E1") = "Number Incorrect"
        oWb.Worksheets(1).Range("F1") = "Percentage"
    End If
    row = 2
    While oWb.Worksheets(1).Range("A" & row) <> ""
        row = row + 1
    Wend
    oWb.Worksheets(1).Range("A" & row) = strTitle
    oWb.Worksheets(1).Range("B" & row) = strdate
    oWb.Worksheets(1).Range("C" & row) = userName
    oWb.Worksheets(1).Range("D" & row) = numCorrect
    oWb.Worksheets(1).Range("E" & row) = numIncorrect
    oWb.Worksheets(1).Range("F" & row) = Format(100 * (numCorrect / (numCorrect + numIncorrect)), "##.#") & "%"
    oWb.Save
    oWb.Close 'penso che vada sostituito. Ma con cosa??
End Sub


Vorrei invece che:
1) il file excel restasse aperto ma andando sul foglio di lavoro "START"
2) chiudesse la presentazione Powerpoint in corso.
Pensavo di raggiungere lo scopo aggiungendo queste righe alla fine della macro :oops: :
Codice: Seleziona tutto
With Application.Presentations("pres1.ppt")
    .Saved = True
    .Close
         End With


Grazie per l'aiuto.
BG66
Excel2010
Avatar utente
BG66
Utente Senior
 
Post: 320
Iscritto il: 20/08/16 07:44

Sponsor
 

Re: [PPT] chiudere presentazione ed aprire file Excel

Postdi patel » 18/02/18 11:42

sostituisci
oWb.Close
con
oWb.Worksheets("START").Select
patel
Utente Senior
 
Post: 309
Iscritto il: 24/04/12 16:03


Torna a Applicazioni Office Windows


Topic correlati a "[PPT] chiudere presentazione ed aprire file Excel":


Chi c’è in linea

Visitano il forum: Nessuno e 92 ospiti

cron