Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Workbooks.add (?RefName?)


I've written out the following code but when I try and reference it
later on in the code, it keeps telling me 'Object Required'.

Sub AddNew()
Dim NewBook As Workbook

Set NewBook = Workbooks.Add
With NewBook
..Title = "Purchase Order"
..Subject = mycount
End With

End Sub

Sub MoveSheet()
ThisWorkbook.Worksheets(1).Move Befo=NewBook.Worksheets(1)
End Sub

When I type in 'NewBook.' it pops up with the menu but when the code
runs it tells me that I require an object.

I was given this code the other day:

Dim NewWB As WorkBook
Set NewWB=Workbook.Add (..../ Workbook.Open (....

I'm not sure what was meant by the code after 'Add'. Does this have
some involvement in referencing the NewWB?

Kartune85


--
kartune85
------------------------------------------------------------------------
kartune85's Profile: http://www.excelforum.com/member.php...o&userid=35586
View this thread: http://www.excelforum.com/showthread...hreadid=554795

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Workbooks.add (?RefName?)


I tried putting the 'Dim NewBook As Workbook' outside all of the
procedures but it says only comments can be placed outside Sub
Procedures. I also tried putting it in 'Sub Auto_Open()' but it still
doesn't recognize the reference.

If I put 'NewBook = Workbooks.Add' elsewhere, it won't execute at the
point I want it to execute.

So how do I "move it outside any procedure"? (I assume you're refering
to 'Dim NewBook As Workbook')


--
kartune85
------------------------------------------------------------------------
kartune85's Profile: http://www.excelforum.com/member.php...o&userid=35586
View this thread: http://www.excelforum.com/showthread...hreadid=554795

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Workbooks.add (?RefName?)


I used:

Public NewBook As Workbook

...right at the the top of the page before any procedures. And In the
close procedure I put:

Sub CloseBook()
Set NewBook = Nothing
Application.DisplayAlerts = False
ThisWorkbook.Close
Application.DisplayAlerts = True
End Sub

It all works sweet now. Someone can now open multiple documents without
having conflict errors.

Thanks for your help.

Kartune85


--
kartune85
------------------------------------------------------------------------
kartune85's Profile: http://www.excelforum.com/member.php...o&userid=35586
View this thread: http://www.excelforum.com/showthread...hreadid=554795

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
Regular Workbooks vs. Binary Workbooks Jerry Excel Discussion (Misc queries) 2 April 28th 10 09:11 PM
Updating Workbooks from multiple links Workbooks TimJames Excel Worksheet Functions 1 December 15th 07 03:34 PM
Copy/ move selected data from workbooks to seperate worksheets or workbooks Positive Excel Worksheet Functions 1 August 30th 07 04:54 PM
Display 2 formulas from source workbooks to destination workbooks Excel_seek_help Excel Discussion (Misc queries) 4 April 27th 06 08:13 PM
suddenly my excel workbooks are "shared workbooks" Maggie's mom Excel Discussion (Misc queries) 1 August 28th 05 09:20 PM


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