LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Open and Close another Workbook from VBA

Greetings.

I wrote the following subroutine to open, do some formatting,
and then close a workbook prior to importing its data into my
current workbook:

Sub CleanSrc(src As String)
Set srcApp = New Excel.Application
srcApp.Visible = False
Set srcWkBk = srcApp.Workbooks.Open(myFile)
Set srcSht = srcWkBk.Sheets(1)
srcLast = srcSht.Range("A1").End(xlDown).Row
srcSht.Rows((srcLast + 1) & ":" & (srcLast + 5)).Delete
srcWkBk.Close (True)
Set srcWkBk = Nothing
Set srcApp = Nothing
End Sub

My problem is that later when I attempt to import data from
this workbook, I get complaints it being locked (by myself!)
and read only.

It appears that somehow this workbook is never really closed
and/or the application I spun up wasn't exited properly.

Can somebody please tell me what I can do to fix this problem?

Regards,

Charles
 
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
Before close and workbook open! Marc[_20_] Excel Programming 1 March 17th 05 01:06 PM
How can I close only 1 workbook when I have many open? jpt consulting Excel Discussion (Misc queries) 3 November 30th 04 11:58 PM
Open, print and close workbook despistado[_3_] Excel Programming 0 November 11th 04 03:02 PM
Close Open Workbook David Coleman Excel Programming 1 December 30th 03 05:53 PM
Close Open Workbook Bob Umlas[_3_] Excel Programming 1 December 30th 03 05:50 PM


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