LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default [hlp]: How to copy a sheet to new wkbook and close the var at the end


Bumping with more details.

I've this piece of test code and I'm having problems because at the end
the -wkInterligBook- wkbook doesn't unload with the -Set wkInterligBook
= Nothing- command.

Can someone help me?


Code:
--------------------
Sub Test()

Dim sFullPathToInterligFile As String
Dim sFullPathToFinalFile As String
Dim wkInterligBook As Workbook

Dim con As ADODB.Connection


sFullPathToInterligFile = ThisWorkbook.Path & "\Test_File.xls"
sFullPathToFinalFile = ThisWorkbook.Path & "\Test_File_Copy.xls"

Set wkInterligBook = Workbooks.Open(sFullPathToInterligFile)

wkInterligBook.Sheets(1).Copy
wkInterligBook.Close
Set wkInterligBook = Nothing

Set wkInterligBook = ActiveWorkbook
wkInterligBook.SaveAs sFullPathToFinalFile

DBEngine.RegisterDatabase "MS Excel Database", _
"Microsoft Excel Driver (*.xls)", True, _
"DBQ=" & sFullPathToFinalFile & ";DESCRIOTION=ODBC para Excel"

Set con = New ADODB.Connection
con.Open "Data Source=MS Excel Database"
con.CursorLocation = adUseClient

' (...)
' (...)
' (...)
' (...)
' (...)

con.Close
Set con = Nothing

wkInterligBook.Save
wkInterligBook.Close
Set wkInterligBook = Nothing
End Sub
--------------------


The references are the following
[image:
http://i22.photobucket.com/albums/b3...eferences.jpg]

and you need to have an (any) excel file name -Test_File.xls- in the
running folder.


--
pao_e_vinho
------------------------------------------------------------------------
pao_e_vinho's Profile: http://www.excelforum.com/member.php...o&userid=21360
View this thread: http://www.excelforum.com/showthread...hreadid=554625

 
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
Update Cell in WKBook 1 From WkBook 2 pattlee Excel Discussion (Misc queries) 2 May 25th 08 01:27 PM
How do I make sure my Wkbook is accessible to users using earlier Mifty Excel Discussion (Misc queries) 1 May 12th 08 01:30 PM
How to link to a single wksheet in a wkbook that has comments RedRobyn Excel Discussion (Misc queries) 1 June 27th 06 07:40 PM
how do i create a dialog box to appear on opening an excel wkbook lallyboo Excel Discussion (Misc queries) 1 October 13th 05 06:52 PM
Can changes to a worksheet be applied to all wksheets in wkbook? SandyM Excel Worksheet Functions 1 September 18th 05 06:21 PM


All times are GMT +1. The time now is 03:33 AM.

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"