Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Difficulties Opening, copying from another workbook and closing

I have the following script to open another workbook, copy certain
information, going back to the original macro driven workbook and then
closing the file source. It works okay, however it gets hung up for a
long period of time before the file closes. Any ideas what I'm doing
wrong?

Sub ImportUnusual()

Dim WorkbookName As String
Dim FileToOpen As String
Dim WorkbookName1 As String

Sheets("UnU DL").Select
Cells.Select
Selection.Clear
Selection.FormatConditions.Delete
Selection.Interior.ColorIndex = xlNone
Range("A1").Select
WorkbookName = Range("A1").Parent.Parent.Name
MsgBox "Please select the file with the inventory by customer data
you wish to import."
FileToOpen = Application _
.GetOpenFilename("Text Files (*.XLS), *.XLS")
If FileToOpen = "False" Then
End If
Workbooks.Open Filename:=FileToOpen
Range("A1").Select
WorkbookName1 = Range("A1").Parent.Parent.Name
Range("H3").Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows(WorkbookName).Activate
Windows(WorkbookName1).Close Savechanges:=False
Windows(WorkbookName).Activate
Range("A1").Select
ActiveSheet.Paste
Range("A1").Select
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,092
Default Difficulties Opening, copying from another workbook and closing

Try this:
Sub ImportUnusual()

Dim WorkbookName As String
Dim FileToOpen As String
Dim WorkbookName1 As String

Sheets("UnU DL").Cells.Clear
WorkbookName = ThisWorkbook.Name
MsgBox "Please select the file with the inventory by customer data you
wish to import."
FileToOpen = Application _
.GetOpenFilename("Text Files (*.XLS), *.XLS")
If FileToOpen = "False" Then
Exit Sub 'if no file selected
End If
Workbooks.Open Filename:=FileToOpen
WorkbookName1 = ActiveWorkbook.Name
Range("H3").Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy Workbooks(WorkbookName).Worksheets("UnU DL").Range("A1")
Windows(WorkbookName1).Close Savechanges:=False

End Sub

Mike F
"Corrie" wrote in message
oups.com...
I have the following script to open another workbook, copy certain
information, going back to the original macro driven workbook and then
closing the file source. It works okay, however it gets hung up for a
long period of time before the file closes. Any ideas what I'm doing
wrong?

Sub ImportUnusual()

Dim WorkbookName As String
Dim FileToOpen As String
Dim WorkbookName1 As String

Sheets("UnU DL").Select
Cells.Select
Selection.Clear
Selection.FormatConditions.Delete
Selection.Interior.ColorIndex = xlNone
Range("A1").Select
WorkbookName = Range("A1").Parent.Parent.Name
MsgBox "Please select the file with the inventory by customer data
you wish to import."
FileToOpen = Application _
.GetOpenFilename("Text Files (*.XLS), *.XLS")
If FileToOpen = "False" Then
End If
Workbooks.Open Filename:=FileToOpen
Range("A1").Select
WorkbookName1 = Range("A1").Parent.Parent.Name
Range("H3").Select
Range(Selection, Selection.End(xlToLeft)).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Windows(WorkbookName).Activate
Windows(WorkbookName1).Close Savechanges:=False
Windows(WorkbookName).Activate
Range("A1").Select
ActiveSheet.Paste
Range("A1").Select
End Sub



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
Opening another workbook and then closing it. Pasty Excel Programming 2 April 4th 07 10:20 AM
Closing a workbook upon opening another Dave New Users to Excel 3 January 3rd 07 09:57 PM
Copying a Range from a Workbook without opening in memory. Richard Buttrey Excel Programming 3 April 7th 06 02:26 PM
opening & copying to a workbook mwc0914[_8_] Excel Programming 0 November 18th 05 06:12 PM
Opening and closing workbook with VBA... Trevor[_4_] Excel Programming 1 March 4th 04 08:33 PM


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