LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Open File then Set as

Do you have some code such as

Set xlApp = New Excel.Application

or

Set xlApp = CreateObject("Excel.Application")

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"MacroLearning" wrote in message
...
I'm sorry - I don't know what that means...


"Bob Phillips" wrote:

Do you have ann. application object variable?

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"MacroLearning" wrote in
message
...
Thank you for posting an answer to my question.

I am still getting a "debug" when I try to execute the macro. It won't
set
the opened file as xlbook. I get a 424 error code. I changed it to
include
your suggestion.

Dim sFile
sFile = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
If sFile < False Then
Set xlBook = Workbook.Open(sFile) <<<========== this is where it hangs
up
at
Set xlSheet1 = xlBook.Worksheets("Headcount Detail")
Set xlBook2 = Workbooks.Open( _
"W:\\Distribution File Cuts\Headcount by Bank Title - Quirk.xls")
Set xlSheet2 = xlBook2.Worksheets("Headcount Detail")
Set xlSheet7 = xlBook1.Worksheets("Headcount Summary")
Set xlSheet8 = xlBook2.Worksheets("Headcount Summary")
xlSheet1.Range("A1:H232").Copy xlSheet2.Range("A1")
xlSheet7.Range("A1:J21").Copy xlSheet8.Range("A1")
xlSheet2.Rows("40:47").Delete

Any help would be greatly appreciated.


"Bob Phillips" wrote:

Dim sFile
sFile = Application.GetOpenFilename("Excel Files (*.xls), *.xls")
If sFile < False Then
Set xlBook = Workbook.Open(sFile)
End If


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)


"MacroLearning" wrote in
message
...
Hi all,
I have a macro that works as I want. When I first started building
I
included the original filename to copy from. That file will change
every
month. So I want the user to open the file, when the file is
opened,
it
will
become "xlBook1". following is the code. I'm getting a debug at
that
point,
but am not sure how to get past it.

Any help will be very much appreciated!

'Book 1 is Headcount by Detail Report
Dim xlBook1 As Excel.Workbook
'Book 2 is Quirk (all except SSGA)
Dim xlBook2 As Excel.Workbook
'Sheet7 is HC Summary worksheet from HC Detail Report
Dim xlSheet7 As Excel.Worksheet
'Sheet8 is HC Summary worksheet for Quirk
Dim xlSheet8 As Excel.Worksheet

'Copy and Paste from Headcount Detail to Quirk
Set xlBook1 = Application.GetOpenFilename <=====This is the problem
here
Set xlSheet1 = xlBook1.Worksheets("Headcount Detail")
Set xlBook2 = Workbooks.Open( _
"C:\\Distribution File Cuts\Headcount by Title - Quirk.xls")
Set xlSheet2 = xlBook2.Worksheets("Headcount Detail")
Set xlSheet7 = xlBook1.Worksheets("Headcount Summary")
Set xlSheet8 = xlBook2.Worksheets("Headcount Summary")
xlSheet1.Range("A1:H232").Copy xlSheet2.Range("A1")
xlSheet7.Range("A1:J21").Copy xlSheet8.Range("A1")
xlSheet2.Rows("40:47").Delete








 
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
Unable to open a 82 KB XLSM file due to "Too many different cellformats" & "Converter failed to open the file." errors. Phillip Pi Excel Discussion (Misc queries) 0 April 23rd 09 08:53 PM
In Excel - Use Windows Explorer instead of File Open to open file KymY Excel Discussion (Misc queries) 1 August 5th 06 09:59 PM
Open a file do a macro ( made) and open next succesive file SVTman74 Excel Programming 5 April 21st 06 10:14 PM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 2 July 8th 05 05:51 AM
Open File or Switch Between Windows if File is Open Ricky Pang Excel Programming 0 July 2nd 05 08:41 PM


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