Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Please help, file name issue



How do I setup a macro to where no matter what file runs
the macro, it will open up a file named "email quote".
If I create the macro in book1 and then save the file to a
different name, the macro is always looking for "book1",
(subscript out of range, error)
instead of what ever the current file name is. Thanks for
any help.

Here is the code

Workbooks.Open Filename:= _
"C:\Documents and Settings\user\Desktop\Email
quote.xls"
Windows("Book1").Activate
Sheets("Sheet1").Select
Range("A1:A6").Select
Selection.Copy
Windows("Email quote.xls").Activate
Range("A1").Select
ActiveSheet.Paste
Range("A8").Select
Windows("Book1").Activate
End Sub




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Please help, file name issue

Brad,

Try something like

Dim AWB As Workbook
Set AWB = ActiveWorkbook
Workbooks.Open Filename:= _
"C:\Documents and Settings\user\Desktop\Email quote.xls"
AWB.Activate
Sheets("Sheet1").Select
Range("A1:A6").Select
Selection.Copy
Windows("Email quote.xls").Activate
Range("A1").Select
ActiveSheet.Paste
Range("A8").Select
AWB.Activate
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"brad" wrote in message
...


How do I setup a macro to where no matter what file runs
the macro, it will open up a file named "email quote".
If I create the macro in book1 and then save the file to a
different name, the macro is always looking for "book1",
(subscript out of range, error)
instead of what ever the current file name is. Thanks for
any help.

Here is the code

Workbooks.Open Filename:= _
"C:\Documents and Settings\user\Desktop\Email
quote.xls"
Windows("Book1").Activate
Sheets("Sheet1").Select
Range("A1:A6").Select
Selection.Copy
Windows("Email quote.xls").Activate
Range("A1").Select
ActiveSheet.Paste
Range("A8").Select
Windows("Book1").Activate
End Sub






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 32
Default Please help, file name issue

As my son would say, "Genius!" Thanks Chip, that is
exactly what I am looking for.

-----Original Message-----
Brad,

Try something like

Dim AWB As Workbook
Set AWB = ActiveWorkbook
Workbooks.Open Filename:= _
"C:\Documents and Settings\user\Desktop\Email

quote.xls"
AWB.Activate
Sheets("Sheet1").Select
Range("A1:A6").Select
Selection.Copy
Windows("Email quote.xls").Activate
Range("A1").Select
ActiveSheet.Paste
Range("A8").Select
AWB.Activate
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"brad" wrote in

message
...


How do I setup a macro to where no matter what file runs
the macro, it will open up a file named "email quote".
If I create the macro in book1 and then save the file

to a
different name, the macro is always looking for "book1",
(subscript out of range, error)
instead of what ever the current file name is. Thanks

for
any help.

Here is the code

Workbooks.Open Filename:= _
"C:\Documents and Settings\user\Desktop\Email
quote.xls"
Windows("Book1").Activate
Sheets("Sheet1").Select
Range("A1:A6").Select
Selection.Copy
Windows("Email quote.xls").Activate
Range("A1").Select
ActiveSheet.Paste
Range("A8").Select
Windows("Book1").Activate
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
XLS file assocation issue nolanstern Excel Discussion (Misc queries) 1 March 14th 10 04:56 PM
Opening File Issue? Ken Excel Discussion (Misc queries) 2 June 1st 09 03:19 PM
I am having issue with excel file Brahama Kroma Excel Discussion (Misc queries) 0 August 6th 08 11:28 PM
Opening Excel file issue? Rick S. Excel Discussion (Misc queries) 0 October 10th 07 03:16 PM
File Opening issue jerminski73 Excel Worksheet Functions 0 April 25th 07 03:30 PM


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