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

Hi! I have a macro that opens a file and goes through a list. If ceratian
things are found in the list I want to open an Excel file and read from that
file to the original file. How do I open an excel file from a macro and how
can I read from it? Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Open excel workbook within macro

This is right out of VBA help file.

Sub OpenUp()
Workbooks.Open("C:\MyFolder\MyBook.xls")
End Sub

If the file you want to open is in the same directory as the active
workbook, then you don't need the full path. Once open, you can access it
and manipulate data much the same as the active sheet, but you will need to
use the workbook and sheet references as you do it like.

Workbooks("MyBook"),Sheets(1).Range("A1:B5").Copy
Workbooks(ActiveWorkbook).Sheets(1).Range("A1")

Good Luck.

"Arne Hegefors" wrote:

Hi! I have a macro that opens a file and goes through a list. If ceratian
things are found in the list I want to open an Excel file and read from that
file to the original file. How do I open an excel file from a macro and how
can I read from it? Thanks!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Open excel workbook within macro

Sub Macro1()
Workbooks.Open Filename:="C:\surprise.xls"
MsgBox (Range("A1").Value)
End Sub

--
Gary''s Student - gsnu200754
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 226
Default Open excel workbook within macro

Hi Arne

i hope the code below clears things up for you a bit

'open your workbook giving the full location and name
Workbooks.Open ("C:\test\filename.xls")
'activate the workbook you want to work with
Workbooks("filename.xls").Activate
[A1:A20].Copy 'for example
'activate the original workbook and paste
Workbooks("original.xls").Activate
[A1].PasteSpecial (xlPasteAll)

hope this helps

Steve


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
Opening Excel, Book1 opens, remains open with other workbook open DanieB Excel Discussion (Misc queries) 0 September 3rd 09 08:23 AM
Excel macro to open a password protected workbook Stephen C Excel Discussion (Misc queries) 8 December 1st 08 05:36 AM
Open workbook macro- find correct month to open? buzzharley[_10_] Excel Programming 8 July 8th 06 04:30 AM
Excel 2003 - Keep a Macro Running While the Workbook is Open MaxRoberts22 Excel Programming 4 January 10th 06 07:33 PM
Excel - open a new workbook with "own" macro Danny Excel Worksheet Functions 3 August 24th 05 06:51 PM


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

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

About Us

"It's about Microsoft Excel"