Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Workbooks.Add question

I have the following line of code in a workbook that I'm working on.

Workbooks.Add ThisWorkbook.Path + "\" + "MyTempWrkSht.xls"

when I get to this line, it opens the workbook that's listed. I thought
Workbooks.Add created a new workbook. Can someone please help me with my
confusion.

Thanks,
Barb Reinhardt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default Workbooks.Add question

According the the help files, the Add Method for a Workbook Object...

"Creates a new workbook. The new workbook becomes the active workbook."

--
Rick (MVP - Excel)


"Barb Reinhardt" <Barb wrote in message
...
I have the following line of code in a workbook that I'm working on.

Workbooks.Add ThisWorkbook.Path + "\" + "MyTempWrkSht.xls"

when I get to this line, it opens the workbook that's listed. I thought
Workbooks.Add created a new workbook. Can someone please help me with my
confusion.

Thanks,
Barb Reinhardt


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Workbooks.Add question

I thought
Workbooks.Add created a new workbook.


It does. If you add a valid filename that'll open as a template.

In passing, although + works to concatenate strings best to use &. In some
scenarios not the same.


Regards,
Peter T

"Barb Reinhardt" <Barb wrote in message
...
I have the following line of code in a workbook that I'm working on.

Workbooks.Add ThisWorkbook.Path + "\" + "MyTempWrkSht.xls"

when I get to this line, it opens the workbook that's listed. I thought
Workbooks.Add created a new workbook. Can someone please help me with my
confusion.

Thanks,
Barb Reinhardt



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Workbooks.Add question


The Add method takes as an optional parameter a Template file name. If
this is supplied, it uses that file as a template. For example,

Workbooks.Add
just opens a new workbook (based on Book.xlt if that exists in the
XLStart directory).

Workbooks.Add "C:\Book1.xls"
opens a new workbook based on C:\Book1.xls. You'll notice that a "1"
is appended to the file name, so the file open in Excel would be
C:\Book11.xls.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Thu, 19 Mar 2009 12:24:00 -0700, Barb Reinhardt <Barb
wrote:

I have the following line of code in a workbook that I'm working on.

Workbooks.Add ThisWorkbook.Path + "\" + "MyTempWrkSht.xls"

when I get to this line, it opens the workbook that's listed. I thought
Workbooks.Add created a new workbook. Can someone please help me with my
confusion.

Thanks,
Barb Reinhardt

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Workbooks.Add question

Just a typo...

The workbook that was created wouldn't have the extension (or path). It would
just be named:

Book11



Chip Pearson wrote:

The Add method takes as an optional parameter a Template file name. If
this is supplied, it uses that file as a template. For example,

Workbooks.Add
just opens a new workbook (based on Book.xlt if that exists in the
XLStart directory).

Workbooks.Add "C:\Book1.xls"
opens a new workbook based on C:\Book1.xls. You'll notice that a "1"
is appended to the file name, so the file open in Excel would be
C:\Book11.xls.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Thu, 19 Mar 2009 12:24:00 -0700, Barb Reinhardt <Barb
wrote:

I have the following line of code in a workbook that I'm working on.

Workbooks.Add ThisWorkbook.Path + "\" + "MyTempWrkSht.xls"

when I get to this line, it opens the workbook that's listed. I thought
Workbooks.Add created a new workbook. Can someone please help me with my
confusion.

Thanks,
Barb Reinhardt


--

Dave Peterson


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Workbooks.Add question


As usual, you're right.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Thu, 19 Mar 2009 16:52:58 -0500, Dave Peterson
wrote:

Just a typo...

The workbook that was created wouldn't have the extension (or path). It would
just be named:

Book11



Chip Pearson wrote:

The Add method takes as an optional parameter a Template file name. If
this is supplied, it uses that file as a template. For example,

Workbooks.Add
just opens a new workbook (based on Book.xlt if that exists in the
XLStart directory).

Workbooks.Add "C:\Book1.xls"
opens a new workbook based on C:\Book1.xls. You'll notice that a "1"
is appended to the file name, so the file open in Excel would be
C:\Book11.xls.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Thu, 19 Mar 2009 12:24:00 -0700, Barb Reinhardt <Barb
wrote:

I have the following line of code in a workbook that I'm working on.

Workbooks.Add ThisWorkbook.Path + "\" + "MyTempWrkSht.xls"

when I get to this line, it opens the workbook that's listed. I thought
Workbooks.Add created a new workbook. Can someone please help me with my
confusion.

Thanks,
Barb Reinhardt

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Workbooks.Add question

I'll take the easy questions!

Chip Pearson wrote:

As usual, you're right.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Thu, 19 Mar 2009 16:52:58 -0500, Dave Peterson
wrote:

Just a typo...

The workbook that was created wouldn't have the extension (or path). It would
just be named:

Book11



Chip Pearson wrote:

The Add method takes as an optional parameter a Template file name. If
this is supplied, it uses that file as a template. For example,

Workbooks.Add
just opens a new workbook (based on Book.xlt if that exists in the
XLStart directory).

Workbooks.Add "C:\Book1.xls"
opens a new workbook based on C:\Book1.xls. You'll notice that a "1"
is appended to the file name, so the file open in Excel would be
C:\Book11.xls.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Thu, 19 Mar 2009 12:24:00 -0700, Barb Reinhardt <Barb
wrote:

I have the following line of code in a workbook that I'm working on.

Workbooks.Add ThisWorkbook.Path + "\" + "MyTempWrkSht.xls"

when I get to this line, it opens the workbook that's listed. I thought
Workbooks.Add created a new workbook. Can someone please help me with my
confusion.

Thanks,
Barb Reinhardt


--

Dave Peterson
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
Sharing workbooks question JoAnn Excel Discussion (Misc queries) 2 April 3rd 08 07:13 PM
Linking to other workbooks question eugene Excel Discussion (Misc queries) 4 July 2nd 07 08:50 AM
Question : Workbooks or Worksheets? WTG Excel Worksheet Functions 1 March 1st 06 09:14 PM
Multiple workbooks question Bambi Williams Excel Discussion (Misc queries) 1 October 12th 05 08:01 PM
One formula on multiple workbooks question Josh M Excel Discussion (Misc queries) 1 May 24th 05 03:17 AM


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