Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default opening a workbook with VBA

I must be thick. How can I open a workbook with VBA?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default opening a workbook with VBA

Workbooks.Open("path to your workbook\name of your workbook.xls")


On Apr 8, 4:15*pm, wrote:
I must be thick. How can I open a workbook with VBA?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default opening a workbook with VBA

Sorry the brackets are not required as it's being used as a procedure
not a function.

Workbooks.Open "path to your workbook\name of your workbook.xls"

Cheers,
Jason Lepack

On Apr 8, 4:24*pm, Jason Lepack wrote:
Workbooks.Open("path to your workbook\name of your workbook.xls")

On Apr 8, 4:15*pm, wrote:



I must be thick. How can I open a workbook with VBA?- Hide quoted text -


- Show quoted text -


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default opening a workbook with VBA

On 8 Apr, 21:25, Jason Lepack wrote:
Sorry the brackets are not required as it's being used as a procedure
not a function.

Workbooks.Open "path to your workbook\name of your workbook.xls"

Cheers,
Jason Lepack

On Apr 8, 4:24*pm, Jason Lepack wrote:



Workbooks.Open("path to your workbook\name of your workbook.xls")


On Apr 8, 4:15*pm, wrote:


I must be thick. How can I open a workbook with VBA?- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


Thanks very much Jason! You have proved my thickness. I was using
brackets instead of quotes.....another day wasted<sigh Thanks again.
Wayne
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default opening a workbook with VBA

Now, if you were intending to do more with that worksheet then these
are some common variables that I use:

option explicit
public sub do_stuff_with_wb()
dim wb as workbook
dim ws as Worksheet
dim r as range

set wb = Workbooks.open("wb_path\wb_name.xls")
set ws = wb.activesheet ' uses the active sheet of the workbook just
opened
set ws = wb.sheets(2) ' uses the second sheet of the workbook

set ws = wb.sheets.add
ws.name = "your_sheet"

set r = ws.range("A1") ' r points to cell A1 of your_sheet
set r = ws.offset(2,2) ' moves two rows down and two colums right
(C3)
set r = ws.offset(-1,-1) ' moves one row up and one column left (B2)

r.value = "Hi!" ' sets the value of B2 to "Hi!"

set r = nothing
set ws = nothing
set wb = nothing
end sub

Cheers,
Jason Lepack

On Apr 9, 3:27 am, wrote:
On 8 Apr, 21:25, Jason Lepack wrote:



Sorry the brackets are not required as it's being used as a procedure
not a function.


Workbooks.Open "path to your workbook\name of your workbook.xls"


Cheers,
Jason Lepack


On Apr 8, 4:24 pm, Jason Lepack wrote:


Workbooks.Open("path to your workbook\name of your workbook.xls")


On Apr 8, 4:15 pm, wrote:


I must be thick. How can I open a workbook with VBA?- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


Thanks very much Jason! You have proved my thickness. I was using
brackets instead of quotes.....another day wasted<sigh Thanks again.
Wayne


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 stop blank workbook from opening when opening an existing kjg Excel Discussion (Misc queries) 3 February 12th 10 09:36 PM
excel VBA problem - setting workbook as variable & opening/re-opening safe Excel Programming 1 August 20th 04 12:22 AM
How to make the opening of a workbook conditional upon the opening of another workbook Marcello do Guzman Excel Programming 1 December 16th 03 06:09 AM
How to make opening of workbook conditional of opening of another workbook turk5555[_2_] Excel Programming 2 December 15th 03 11:07 PM
Preventing opening workbook inside active workbook. Serge[_4_] Excel Programming 2 November 4th 03 07:51 PM


All times are GMT +1. The time now is 04:51 AM.

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"