HansV wrote:Does it help if you insert
Application.DisplayAlerts = False
above the SaveAs line, and
Application.DisplayAlerts = True
below it?
Code: Select all
Private Sub LEGGI_VIRGINIO(NOME_FILE)
Dim cnt As ADODB.Connection
Dim rst As ADODB.Recordset
Dim stSQL As String
Dim vaData As Variant
Dim a(3) As String
'We can either use a range-name or a cellrange as the source
'in the SQL-statement.
stSQL = "SELECT * FROM [PROVA BNT$A2:G27590]"
'If we, like in this case, retrieve data from a specific range we need
'to set the property HDR to No which per se mean that it does not exist any
'fieldnames(columnnames) in the source-sheet.
Const stCon As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\DATABASE\MF\REPORT_20140318 1814.XLS;" & _
"Extended Properties=""Excel 8.0;HDR=NO"";"
'Instantiate and open the ADO COM-server objects.
Set cnt = New ADODB.Connection
Set rst = New ADODB.Recordset
'Open the connection.
cnt.Open stCon
'Open and retrieve the recordset.
rst.Open stSQL, cnt, adOpenForwardOnly, adLockReadOnly, adCmdText
'Check if data is returned.
If Not rst.EOF Then
'Read retrieved recordset into an variant-array.
vaData = rst.GetRows()
Else
MsgBox "No data found!", vbInformation
GoTo ExitHere
End If
'Populate the array with data.
a(1) = vaData(0, 0)
a(2) = vaData(1, 0)
a(3) = vaData(2, 0)
ExitHere:
'Close and release COM-Objects variables from memory.
rst.Close
Set rst = Nothing
cnt.Close
Set cnt = Nothing
End Sub
now i need to open the new vbk saved with ado to loop recordst...
2 prob_
- the sheet in select have a blank space into the name
- i need to trap in :
Const stCon As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\DATABASE\MF\REPORT_20140318 1814.XLS;" & _
"Extended Properties=""Excel 8.0;HDR=NO"";"
the name of varible NOME_FILE instead REPORT_20140318 1814.XLS
other way are welcomed