Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Close workbook problem

I have the following code where I open a workbook, copy page and close
workbook. Excel is "locking up" (hourglass) at close workbook line. I have
used this same code in other applications with no problem. Any ideas?

Sheets("Directory").Select
Yr = Cells(2, 2)
Mth = Cells(4, 2)
Location = Cells(7, 2)
CAFile = Cells(8, 2)
ctpage = Cells(9, 2)
CTup = Cells(14, 2)

Dim bk As Workbook
Set bk = Workbooks.Open(Location & Yr & "\" & Mth & "\" & CAFile,
UpdateLinks:=False)


Dim wbkSource As Workbook
Dim wbkDestination As Workbook
Dim wksSource As Worksheet
Dim wksDestination As Worksheet
Dim rngSource As Range
Dim rngDestination As Range

Set wbkSource = Workbooks(CAFile)
Set wksSource = wbkSource.Sheets(ctpage)
Set rngSource = wksSource.Cells

Set wbkDestination = ThisWorkbook
Set wksDestination = wbkDestination.Sheets(CTup)
Set rngDestination = wksDestination.Range("A1")

rngSource.Copy
rngDestination.PasteSpecial (xlPasteValues)


Windows(CAFile).Activate
Application.DisplayAlerts = False
ActiveWorkbook.Close SaveChanges:=False
Application.DisplayAlerts = True

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Close workbook problem

Don,

Does Cells(8, 2) include the file extension?

You have the bk variable set as the opened workbook.
Why use another variable (wbkSource) for the same thing?

Do you really need to copy all 17 million cells?
(Sheet.Cells means all of them)

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware




"Don S"
wrote in message

I have the following code where I open a workbook, copy page and close
workbook. Excel is "locking up" (hourglass) at close workbook line. I have
used this same code in other applications with no problem. Any ideas?

Sheets("Directory").Select
Yr = Cells(2, 2)
Mth = Cells(4, 2)
Location = Cells(7, 2)
CAFile = Cells(8, 2)
ctpage = Cells(9, 2)
CTup = Cells(14, 2)

Dim bk As Workbook
Set bk = Workbooks.Open(Location & Yr & "\" & Mth & "\" & CAFile,
UpdateLinks:=False)


Dim wbkSource As Workbook
Dim wbkDestination As Workbook
Dim wksSource As Worksheet
Dim wksDestination As Worksheet
Dim rngSource As Range
Dim rngDestination As Range

Set wbkSource = Workbooks(CAFile)
Set wksSource = wbkSource.Sheets(ctpage)
Set rngSource = wksSource.Cells

Set wbkDestination = ThisWorkbook
Set wksDestination = wbkDestination.Sheets(CTup)
Set rngDestination = wksDestination.Range("A1")

rngSource.Copy
rngDestination.PasteSpecial (xlPasteValues)


Windows(CAFile).Activate
Application.DisplayAlerts = False
ActiveWorkbook.Close SaveChanges:=False
Application.DisplayAlerts = True

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Close workbook problem

Yes

redundant, but still works

no, don't need all cells,but just as easy to copy entire page.

everything works fine with the copy until I try to close the workbook


"Jim Cone" wrote:

Don,

Does Cells(8, 2) include the file extension?

You have the bk variable set as the opened workbook.
Why use another variable (wbkSource) for the same thing?

Do you really need to copy all 17 million cells?
(Sheet.Cells means all of them)

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware




"Don S"
wrote in message

I have the following code where I open a workbook, copy page and close
workbook. Excel is "locking up" (hourglass) at close workbook line. I have
used this same code in other applications with no problem. Any ideas?

Sheets("Directory").Select
Yr = Cells(2, 2)
Mth = Cells(4, 2)
Location = Cells(7, 2)
CAFile = Cells(8, 2)
ctpage = Cells(9, 2)
CTup = Cells(14, 2)

Dim bk As Workbook
Set bk = Workbooks.Open(Location & Yr & "\" & Mth & "\" & CAFile,
UpdateLinks:=False)


Dim wbkSource As Workbook
Dim wbkDestination As Workbook
Dim wksSource As Worksheet
Dim wksDestination As Worksheet
Dim rngSource As Range
Dim rngDestination As Range

Set wbkSource = Workbooks(CAFile)
Set wksSource = wbkSource.Sheets(ctpage)
Set rngSource = wksSource.Cells

Set wbkDestination = ThisWorkbook
Set wksDestination = wbkDestination.Sheets(CTup)
Set rngDestination = wksDestination.Range("A1")

rngSource.Copy
rngDestination.PasteSpecial (xlPasteValues)


Windows(CAFile).Activate
Application.DisplayAlerts = False
ActiveWorkbook.Close SaveChanges:=False
Application.DisplayAlerts = True


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
Help on Workbook close and workbook save events Adam Harding Excel Programming 1 September 29th 05 04:12 PM
Before Close workbook? Marc[_20_] Excel Programming 1 March 18th 05 07:19 PM
close only one workbook bobsmom70601 New Users to Excel 1 March 8th 05 09:43 PM
workbook.close savechanges:=True problem Dave the Wave Excel Programming 3 January 19th 05 08:44 PM
Close a the current workbook and load another specified workbook Adrian[_7_] Excel Programming 4 August 7th 04 05:29 PM


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