Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default how to access data from excel to/from another program using Vb

Do you have a code sample?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default how to access data from excel to/from another program using Vb

Dear Abel

Try below code after referencing Microsoft Excel Object Library

If this post helps click Yes
---------------
Jacob Skaria


Dim xlApp As Excel.Application
Dim xlWB1 As Excel.Workbook

Set xlWB1 = xlApp.OpenWorkbook("c:\temp.xls")
'Read values
strTemp = xlWB1.Sheets(1).Range("A1")
xlWB1.Close
Set xlWB1 = Nothing

xlApp.Quit
Set xlApp = Nothing


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default how to access data from excel to/from another program using Vb

To use that code, you will need to set a reference to the Excel Object
Library.

See the article "Control Excel from Word" at:

http://www.word.mvps.org/FAQs/InterD...XLFromWord.htm

and the article "Early vs. Late Binding" at:

http://www.word.mvps.org/FAQs/InterD...ateBinding.htm




--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Jacob Skaria" wrote in message
...
Dear Abel

Try below code after referencing Microsoft Excel Object Library

If this post helps click Yes
---------------
Jacob Skaria


Dim xlApp As Excel.Application
Dim xlWB1 As Excel.Workbook

Set xlWB1 = xlApp.OpenWorkbook("c:\temp.xls")
'Read values
strTemp = xlWB1.Sheets(1).Range("A1")
xlWB1.Close
Set xlWB1 = Nothing

xlApp.Quit
Set xlApp = Nothing




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default how to access data from excel to/from another program using Vb

Let's say you are in Access, for instance, and you want to control Excel.
Follow the logic below:
It is quite easy to perform operations in Excel, and control the entire
process from Access. Make sure you set a reference to Excel, and then run
this code in an Access module:
Option Compare Database

Option Explicit ' Use this to make sure your variables are defined

' One way to be able to use these objects throughout the Module is to
Declare them here, and not in a Sub
Private objExcel As Excel.Application
Private xlWB As Excel.Workbook
Private xlWS As Excel.Worksheet

Sub Rep()
Dim strFile As String

strFile = "C:\filename.xls"

' Of course, this is just an example; put the actual path to your actual
file here€¦

' Opens Excel and makes it Visible

Set objExcel = New Excel.Application

objExcel.Visible = True

' Opens up a Workbook

Set xlWB = objExcel.Workbooks.Open(strFile)

' Sets the Workseet to the last active sheet - Better to use the commented
version and use the name of the sheet.

Set xlWS = xlWB.ActiveSheet

' Set xlWS = xlWB("Sheet1")

With xlWS ' You are now working with the Named file and the named worksheet

' Your Excel code begins here€¦you can even record a macro and make the
process super easy!!

End With

' Close and Cleanup

xlWB.SaveAs xlSaveFile
xlWB.Close
xlapp.Quit

Set xlapp = Nothing

End Sub

Send me an email if you have any questions about controlling Excel from
Access!!

Regards,
Ryan---


--
RyGuy


"Doug Robbins - Word MVP on news.microsof" wrote:

To use that code, you will need to set a reference to the Excel Object
Library.

See the article "Control Excel from Word" at:

http://www.word.mvps.org/FAQs/InterD...XLFromWord.htm

and the article "Early vs. Late Binding" at:

http://www.word.mvps.org/FAQs/InterD...ateBinding.htm




--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"Jacob Skaria" wrote in message
...
Dear Abel

Try below code after referencing Microsoft Excel Object Library

If this post helps click Yes
---------------
Jacob Skaria


Dim xlApp As Excel.Application
Dim xlWB1 As Excel.Workbook

Set xlWB1 = xlApp.OpenWorkbook("c:\temp.xls")
'Read values
strTemp = xlWB1.Sheets(1).Range("A1")
xlWB1.Close
Set xlWB1 = Nothing

xlApp.Quit
Set xlApp = Nothing





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
How do I access the access data via Excel 2002 with auto update ? karthik Excel Programming 1 February 9th 07 01:56 PM
Importing data from Access to Excel, but I need to vary the table from Access Liz L. Excel Programming 3 June 6th 06 02:12 AM
Excel/Access Program Dan[_36_] Excel Programming 1 June 24th 04 12:12 PM
Calling Access Program from Excel John Baker Excel Programming 1 April 24th 04 01:20 PM
Converting Access dll calls to Excel program Pal Excel Programming 1 February 1st 04 04:52 PM


All times are GMT +1. The time now is 12:35 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"