Home > Software engineering >  In office 2003 VBA under normal operation, but the VBA program under the office 2010 run wrong.
In office 2003 VBA under normal operation, but the VBA program under the office 2010 run wrong.

Time:09-28


I use office003, run the following program is normal, but run on Windows 7 64 - bit office2010, suggest a runtime error, lack of at least one parameter,
I check adjusted the SQL statement repeatedly, couldn't solve, please expert advice, thank you very much!
Sub classified summary ()
Dim word As String
If Application. Version="14.0" Then
The word="Microsoft. ACE. The OLEDB. 12.0; Extended properties='excel 12.0; HDR=no. IMEX=1 '; Data source="' corresponding office2010 64 OK"
ElseIf Application. Version="11.0" Then
Word="Microsoft jet. The oledb. 4.0; Extended properties=8.0 excel; Data source="corresponding office2003 OK
'The Else
MsgBox "does not support this version of Excel, please contact the administrator"
End the If
Range (" A2: E100 "). ClearContents
Set the conn=CreateObject (" adodb. Connection ")
Conn. Open "the provider=" & amp; Word & amp; ThisWorkbook. FullName
Sq1="select the category, quantity, amount from [Sheet1 $]"
For sq2="select the category, quantity, amount from $] [Sheet2"
Sq3="select the category, quantity, amount from $] [Sheet3"
Sq4=sq1 & amp; "UNION ALL" & amp; For sq2 & amp; "UNION ALL" & amp; Sq3
Sq5="select category, the SUM (quantity), SUM (amount) from (" & amp; Sq4 & amp; ") GROUP BY category
"[a65536]. End (xlUp). Offset (1, 0). CopyFromRecordset conn. Execute (sq5)
Conn. Close
Set the conn=Nothing
End Sub

CodePudding user response:

Office contains access2010?
  •  Tags:  
  • VBA
  • Related