ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Retrieving data from Excel and store it into string variable (https://www.excelbanter.com/excel-programming/315845-retrieving-data-excel-store-into-string-variable.html)

marsulein[_2_]

Retrieving data from Excel and store it into string variable
 

Dim strTemp As String
Dim objExcel As Object
Dim cnnExcel As String

strTemp = objExcel.Fields("Resource").Value


I open the connection this way:

cnnExcel = "driver={Microsoft Excel Driver (*.xls)};" & _
"dbq=<*some path*;" & _
"Extended Properties=""Exce
8.0;HDR=Yes"""

objExcelAdd.Open "SELECT * FROM [New To be added$]", cnnExcel, 1,

--
marsulei
-----------------------------------------------------------------------
marsulein's Profile: http://www.excelforum.com/member.php...fo&userid=1606
View this thread: http://www.excelforum.com/showthread.php?threadid=27520


NickHK

Retrieving data from Excel and store it into string variable
 
marsulein
If objExcel refers to an instance of Excel, how are you creating/assigning
it ? If true, then Excel does not have a ".Fields" property.

What is objExcelAdd ?

I'm a little confused as to what you are trying to do, so please clarify the
you want to get data from an Excel sheet in to VB using ADO ?

NickHK


"marsulein" wrote in message
...

Dim strTemp As String
Dim objExcel As Object
Dim cnnExcel As String

strTemp = objExcel.Fields("Resource").Value


I open the connection this way:

cnnExcel = "driver={Microsoft Excel Driver (*.xls)};" & _
"dbq=<*some path*;" & _
"Extended Properties=""Excel
8.0;HDR=Yes"""

objExcelAdd.Open "SELECT * FROM [New To be added$]", cnnExcel, 1, 1


--
marsulein
------------------------------------------------------------------------
marsulein's Profile:

http://www.excelforum.com/member.php...o&userid=16064
View this thread: http://www.excelforum.com/showthread...hreadid=275204





All times are GMT +1. The time now is 05:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com