tramite codice VBA da file ACCESS devo formattare un file excel. Tutta la formattazione del codice qui presente mi funziona, mentre quando provo ad inserire codice per allineare verticalmente il testo questo codice non funziona.
Qui di seguito il codice funzionante (senza la parte dell'allineamento verticale)
codice:Dim Date1 As Date, strReportAddress As String Dim objActiveWkb As Object, appExcep As Object Set appExcel = CreateObject("Excel.Application") appExcel.Visible = False appExcel.Application.Workbooks.Open (CurrentProject.Path & "\" & "exportMappature4.xlsx") Set objActiveWkb = appExcel.Application.ActiveWorkbook With objActiveWkb For i = 1 To 23 .Worksheets(1).Cells(1, i).Font.Bold = True .Worksheets(1).Cells(1, i).Interior.ColorIndex = 15 .Worksheets(1).Cells(1, i).EntireColumn.WrapText = True If i < 21 Then .Worksheets(2).Cells(1, i).Font.Bold = True .Worksheets(2).Cells(1, i).Interior.ColorIndex = 15 .Worksheets(2).Cells(1, i).EntireColumn.WrapText = True End If Next i .Worksheets(1).Cells.Select .Worksheets(1).Cells.EntireColumn.AutoFit .Worksheets(2).Cells.EntireColumn.AutoFit For i = 1 To 23 .Worksheets(1).Cells(1, i).WrapText = False If i < 21 Then .Worksheets(2).Cells(1, i).WrapText = False End If Next i .Worksheets(1).Cells.EntireColumn.AutoFit .Worksheets(1).Cells(1, 1).Select '''''''''''''''''''''''''''''''' '''''''''''''''' .Worksheets(2).Cells.EntireColumn.AutoFit End With objActiveWkb.Close savechanges:=True appExcel.Application.Quit

Rispondi quotando

