problemi con excel 2010



  • problemi con excel 2010
    di biss73 (utente non iscritto) data: 22/06/2016 14:09:48

    Salve a tutti ho un piccolo problema da esporvi:
    ho una macro sviluppata e funzionante su Excel 2013, passando alla versione 2010 mi da una serie di errori all'apertura del form (il codice non è compatibile con la versione installata, impossibile trovare il progetto o la libreria)
    posto i due pezzi di macro incriminati nella speranza che qualcuno possa darmi una dritta per risolvere
    Grazie
     
        1° errore
    Utente = UCase(Replace(Environ("USERNAME"), ".", " "))
    
    '2° errore ( Impossibile trovare il progetto o la libreria)
    
    Private Sub TextBox60_Change()
    Dim sh As Worksheet
    Dim riga As Integer
    
    riga = ListBox1.ListIndex
    
    Set sh = ThisWorkbook.Worksheets("Pianificazione_indoor")
    With sh
            For lng = 3 To lRiga
             If .Range("A" & lng).Value = _
                Me.ListBox1.List(Me.ListBox1.ListIndex, 0) Then
                sh.Cells(lng, 19) = Format(Me.TextBox60.Text, "mm/dd/yyyy")
             End If
            Next
    End With
    
    End Sub
    



  • di patel data: 22/06/2016 17:52:36

    non dipende dalla macro, ma dalle userform e dai controlli, allega il file e vediamo se lo fa anche a noi





  • di biss73 (utente non iscritto) data: 23/06/2016 08:22:38

    buongiorno e grazie per l'interesse dimostrato,
    purtroppo non posso allegare il file perchè per come è realizzato e pieno di dati sensibili.
    potresti essere un po più chiaro ( per uno come me che non è molto esperto) all'interno ho inserito un modulo di classe (copiato in rete) che allego.
    per il resto è una useform con una serie di Texbox ( circa 60) che ognuna scrive su una cella del foglio alcune impostate come date e alcune come testo e una listbox che riporta l'elenco delle righe del foglio. Selezionando una voce sulla listbox popolo le texbox.
    se ritieni opportuno posso inviarti il file ( in privato se ciò è permesso nel forum)
    in attesa di riscontri ringrazio


     
    ' modulo di classe per ridurre a icona la useform
    'Chiamo le API
        Private Declare Function FindWindow Lib "user32" _
        Alias "FindWindowA" _
        (ByVal lpClassName As String, _
        ByVal lpWindowName As String) As Long
        
        'prende lo stile corrente
        Private Declare Function GetWindowLong Lib "user32" _
        Alias "GetWindowLongA" _
        (ByVal hWnd As Long, _
        ByVal nIndex As Long) As Long
    
        'Imposta il nuovo stile
        Private Declare Function SetWindowLong Lib "user32" _
        Alias "SetWindowLongA" (ByVal hWnd As Long, _
        ByVal nIndex As Long, _
        ByVal dwNewLong As Long) As Long
    
        Private Declare Function DrawMenuBar Lib "user32" _
        (ByVal hWnd As Long) As Long
    
        Private Declare Function SetFocus Lib "user32" _
        (ByVal hWnd As Long) As Long
        'stile della finestra
        Private Const GWL_STYLE As Long = (-16)
        'stile della finestra esteso
        Private Const GWL_EXSTYLE As Long = (-20)
        'imposta barra del titolo
        Private Const WS_CAPTION As Long = &HC00000
        'imposta barra di chiusura
        Private Const WS_SYSMENU As Long = &H80000
        'imposta finestra ridimensionabile
        Private Const WS_THICKFRAME As Long = &H40000
        'imposta pulsante riduci
        Private Const WS_MINIMIZEBOX As Long = &H20000
        'imposta pulsante ingrandisci
        Private Const WS_MAXIMIZEBOX As Long = &H10000
    
        Private mhWndForm As Long
    
        'Imposto le nuove proprietà
        Public Property Set Form(oForm As Object)
    
            'Ottengo le impostazioni di UserForm in base alle versioni
            If Val(Application.Version) < 9 Then
                'Excel 97
                mhWndForm = FindWindow("ThunderXFrame", oForm.Caption)
            Else
                'Excel 2000 o superiori
                mhWndForm = FindWindow("ThunderDFrame", oForm.Caption)
            End If
    
            SetFormStyle
    
        End Property
    
    
        Private Sub SetFormStyle()
    
            Dim lStyle As Long
    
            lStyle = GetWindowLong(mhWndForm, GWL_STYLE)
            
            '(1) Crea una finestra senza barra del titolo
            'SetWindowLong mhWndForm, GWL_STYLE, lStyle And Not WS_CAPTION
            '(2) Crea una finestra senza pulsante di chiusura
            'SetWindowLong mhWndForm, GWL_STYLE, lStyle And Not WS_SYSMENU
            '(3) Crea una finestra ridimensionabile
            'SetWindowLong mhWndForm, GWL_STYLE, lStyle Or WS_THICKFRAME
            '(4) Crea una finestra ridimensionabile e riducibile a icona
            SetWindowLong mhWndForm, GWL_STYLE, lStyle _
            Or WS_MINIMIZEBOX Or WS_MAXIMIZEBOX
    
            'Aggiorno i cambiamenti
            DrawMenuBar mhWndForm
            SetFocus mhWndForm
        End Sub
        
    ///////////////////////////////////////////////////////////////////////////////
    ' questa invece sulla useform
    Option Explicit
    #If Win64 Then
    
        Private Declare PtrSafe Function FindWindow& Lib "user32" _
            Alias "FindWindowA" (ByVal lpClassName As String, _
            ByVal lpWindowName As String)
        
        Private Declare PtrSafe Function SetWindowLong& Lib "user32" Alias _
            "SetWindowLongA" (ByVal hWnd&, ByVal nIndex&, _
            ByVal dwNewLong As LongLong)
        
        Private Declare PtrSafe Function EnableWindow& Lib "user32" _
            (ByVal hWnd As LongLong, ByVal fEnable As LongLong)
        
        Private Declare PtrSafe Function ShowWindow& Lib "user32" _
            (ByVal hWnd As LongLong, ByVal nCmdShow As LongLong)
    
    #Else
    
        Private Declare Function FindWindow& Lib "user32" _
            Alias "FindWindowA" (ByVal lpClassName As String, _
            ByVal lpWindowName As String)
        
        Private Declare Function SetWindowLong& Lib "user32" Alias _
            "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, _
            ByVal dwNewLong As Long)
        
        Private Declare Function EnableWindow& Lib "user32" _
            (ByVal hWnd As Long, ByVal fEnable As Long)
        
        Private Declare Function ShowWindow& Lib "user32" _
            (ByVal hWnd As Long, ByVal nCmdShow As Long)
        
    #End If
    /////////////////////////////////////////////////////////
    ' questa è per popolare le texbox
    Public Sub mPopolaTextBox()
    Dim lng As Long
         Set sh = ThisWorkbook.Worksheets("Pianificazione_indoor")
          With sh
                
                       For lng = 3 To lRiga
             If .Range("A" & lng).Value = _
                Me.ListBox1.List(Me.ListBox1.ListIndex, 0) Then
                
                Me.TextBox1.Text = .Range("B" & lng).Value ' lancio
                Me.TextBox68.Text = .Range("C" & lng).Value ' cliente
                Me.TextBox53.Text = .Range("D" & lng).Value ' data 
                Me.TextBox3.Text = .Range("E" & lng).Value ' commessa
                Me.TextBox4.Text = .Range("F" & lng).Value ' Descrizione 
                Me.TextBox5.Text = .Range("G" & lng).Value ' prodotto
                Me.TextBox7.Text = .Range("H" & lng).Value ' descr. 
                Me.TextBox8.Text = .Range("I" & lng).Value ' Quantità
                Me.TextBox54.Text = .Range("J" & lng).Value ' Data 
                Me.TextBox10.Text = .Range("K" & lng).Value ' Note 
                Me.TextBox12.Text = .Range("M" & lng).Value ' Stato 
                Me.TextBox14.Text = .Range("N" & lng).Value ' 
                Me.TextBox15.Text = .Range("O" & lng).Value ' 
                Me.TextBox16.Text = .Range("P" & lng).Value ' Ore 
                Me.TextBox17.Text = .Range("Q" & lng).Value ' data 
                
                Me.TextBox47.Text = .Range("R" & lng).Value ' Inizio 
                Me.TextBox18.Text = .Range("S" & lng).Value ' FINE 
    .
                Me.TextBox48.Text = .Range("T" & lng).Value ' Fine 
                Me.TextBox32.Text = .Range("U" & lng).Value ' FINE 
                Me.TextBox61.Text = .Range("V" & lng).Value ' FINE 
                Me.TextBox62.Text = .Range("W" & lng).Value ' NOTE.
                
                
                Me.TextBox26.Text = .Range("X" & lng).Value ' Data 
                Me.TextBox20.Text = .Range("Y" & lng).Value ' 
                Me.TextBox21.Text = .Range("Z" & lng).Value ' Data
                Me.TextBox65.Text = .Range("AA" & lng).Value ' NOTE
                Me.TextBox22.Text = .Range("AB" & lng).Value ' 
                Me.TextBox66.Text = .Range("AC" & lng).Value ' NOTE
                Me.TextBox19.Text = .Range("AD" & lng).Value ' 
                Me.TextBox23.Text = .Range("AE" & lng).Value ' 
                
                Me.TextBox70.Text = .Range("AF" & lng).Value ' 
                Me.TextBox24.Text = .Range("AG" & lng).Value ' 
                
                Me.TextBox25.Text = .Range("AH" & lng).Value ' 
                Me.TextBox67.Text = .Range("AI" & lng).Value ' 
                Me.TextBox58.Text = .Range("AJ" & lng).Value ' 
                Me.TextBox59.Text = .Range("AK" & lng).Value ' 
                
                
                
                
                Me.TextBox27.Text = .Range("AL" & lng).Value ' 
                Me.TextBox28.Text = .Range("AM" & lng).Value ' 
                Me.TextBox29.Text = .Range("AN" & lng).Value ' 
                Me.TextBox30.Text = .Range("AO" & lng).Value ' 
                Me.TextBox31.Text = .Range("AP" & lng).Value ' 
                
                dato1 = .Range("AL" & lng).Value ' 
                dato2 = .Range("AM" & lng).Value ' 
                dato3 = .Range("AN" & lng).Value ' 
                dato4 = .Range("AO" & lng).Value ' 
                dato5 = .Range("AP" & lng).Value ' 
                            
                Me.TextBox34.Text = Me.TextBox1.Text ' 
                Me.TextBox69.Text = Me.TextBox68.Text ' 
                Me.TextBox49.Text = Me.TextBox53.Text ' 
                Me.TextBox36.Text = Me.TextBox3.Text ' 
                Me.TextBox33.Text = Me.TextBox4.Text ' 
                Me.TextBox35.Text = Me.TextBox5.Text ' 
                Me.TextBox37.Text = Me.TextBox7.Text ' 
                Me.TextBox38.Text = Me.TextBox8.Text ' 
                Me.TextBox50.Text = Me.TextBox54.Text ' 
                Me.TextBox39.Text = Me.TextBox10.Text ' 
                Me.TextBox40.Text = Me.TextBox12.Text ' 
                Me.TextBox41.Text = Me.TextBox14.Text ' 
                Me.TextBox42.Text = Me.TextBox15.Text ' 
                Me.TextBox43.Text = Me.TextBox17.Text ' 
                Me.TextBox63.Text = Me.TextBox16.Text ' 
                Me.TextBox64.Text = Me.TextBox62.Text '             
                Me.TextBox51.Text = .Range("R" & lng).Value 
                Me.TextBox60.Text = .Range("S" & lng).Value ' 
                Me.TextBox44.Text = .Range("T" & lng).Value ' 
                Me.TextBox46.Text = .Range("U" & lng).Value 
                Me.TextBox52.Text = .Range("V" & lng).Value 
                Me.TextBox62.Text = .Range("W" & lng).Value 
                
             End If
            Next
            
            
         End With
    
    End Sub
    



  • di patel data: 23/06/2016 08:37:24

    non posso essere più chiaro visto che non ho visto cosa hai fatto, come ti ho detto non dipende dal codice





  • di biss73 (utente non iscritto) data: 23/06/2016 09:03:13

    ciao e grazie ancora
    come posso procedere per farti avere il file in privato ammesso che sia consentito?
    grazie



  • di alfrimpa data: 23/06/2016 12:02:21

    Ciao Biss ed un saluto a Patel

    Purtroppo su questo forum (a differenza di altri) non è disponibile lo strumento dei messaggi privati per cui, a mio avviso, si possono fare due cose:

    1) Ti crei una mail di quelle temporanee in modo che chi voglia possa contattarti senza la necessità di rendere pubblica quella originale (che non è mai buona cosa); non mi chiedere come si fa perché non l'ho mai fatto.

    2) Iscriversi ad altro forum (che ha i messaggi privati) e ripartire da lì.

    Alfredo





  • di patel data: 23/06/2016 12:59:15

    oppure elimini i dati sensibili, occorre un file di esempio, non l'originale





  • di alfrimpa data: 23/06/2016 13:22:32

    Si certo Andrea, quell'ipotesi la davo per scontata.

    Alfredo





  • di biss73 (utente non iscritto) data: 23/06/2016 15:48:40

    salve e grazie ancora per l'interesse,
    andare su altro forum ( come suggerito da Alfredo ) non mi sembra il caso visto che ho sempre esposto e risolto qualsiasi problema QUI
    Allego il file privo di dati sensibili.
    Però premetto: non fate caso (vi prego) all'eleganza della scrittura dei vari codici
    e la confusione generale delle varie macro sparse qua e la
    (di sicuro non farò una bella figura )
    in attesa di un vostro riscontro ringrazio tutti per l'interesse dimostrato



  • di alfrimpa data: 23/06/2016 16:48:16

    Io non ho il 2010 per cui non posso provare.

    Alfredo