Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 53
Default macro linking to excel

How can I create a macro where Outlook can retrieve certain cells from Excel.

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default macro linking to excel

"Judy" wrote in message
...
: How can I create a macro where Outlook can retrieve certain cells from
Excel.
:
: Thanks!

Here's a copy of a post from Jake Marx discussing connecting to Excel using
ADO

<quote
Another way to do this is to use ADO. Here's a function that will return
the value in cell A1 of the first worksheet in a closed workbook. There is
one drawback, however - your data in cell A1 must be non-numeric. If it's a
number, you'll get an invalid result back. So only use this if you expect
all values in A1 to be text. (This function would work fine for any type of
value if you were looking at cells in row 2 and below, FWIW.)


To use this, first set a reference to the "Microsoft ActiveX Data Objects
2.x Library" through Tools | References.


Regards,
Jake Marx


Function vGetA1FromXLFile(rsFullPath As String) As Variant
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset


On Error GoTo ErrHandler


Set cn = New ADODB.Connection
cn.Open "Provider=MSDASQL.1;Data Source=Excel Files;" _
& "Initial Catalog=" & rsFullPath
Set rs = cn.Execute("[A1:A1]")
vGetA1FromXLFile = rs.Fields(0).Name


ExitRoutine:
If Not rs Is Nothing Then
If rs.State = adStateOpen Then rs.Close
Set rs = Nothing
End If
If Not cn Is Nothing Then
If cn.State = adStateOpen Then cn.Close
Set cn = Nothing
End If
Exit Function
ErrHandler:
Resume ExitRoutine
End Function


</quote


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
An error msg in Excel 2007 regarding Linking but no linking in fil Jugglertwo Excel Discussion (Misc queries) 0 September 12th 08 02:08 AM
Linking Macro to Button? Jo[_2_] Excel Discussion (Misc queries) 1 August 2nd 07 08:44 PM
Linking a Macro to a Button bman342 Excel Discussion (Misc queries) 3 April 10th 06 03:35 AM
Macro linking vishu Excel Discussion (Misc queries) 2 July 12th 05 01:16 PM
DATA LINKING MACRO ! jay dean Excel Programming 0 November 6th 03 11:22 PM


All times are GMT +1. The time now is 12:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"