LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 36
Default Active Window Question

The overall goal is for my macro to copy a sheet from the active workbook,
paste it in a new workbook created by the macro. The user will then be asked
to save the new workbook via the "save as" menu. Below is what I have so
far. If anyone has a different method, please let me know.

Option Explicit
Private Sub CreateInfoFile_Click()
Dim mod1name As String
Dim infoname As String
Dim newbook

'inserting full name of active file in Exported Sheet
Sheets("ExportedSheet").Range("B1").Value = mod1name

'Creating New Workbook
Set newbook = Workbooks.Add
With newbook
.SaveAs Filename:="Blank.xls"
End With

'Copy Exported Sheet to new file
Sheets("ExportedSheet").Copy Befo=Workbooks("Blank.xls").Sheets(1)
'*PROBLEM

'Deleting blank sheets
Sheets("Sheet1").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Sheet2").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Sheet3").Select
ActiveWindow.SelectedSheets.Delete
Sheets("Sheet4").Select
ActiveWindow.SelectedSheets.Delete

'Saving new file
Do
infoname = Application.GetSaveAsFilename
Loop Until infoname < False
newbook.SaveAs Filename:=infoname

'Getting filename and pasting in Exported Sheet
Sheets("ExportedSheet").Range("B2").Value = infoname

End Sub

First, I create the newworkbook. No problem. Then I try and copy the sheet
to it. As far as I know, to do this you have to activate the workbook with
the "ExportedSheet" sheet. Since the name of this file will be changing, I
need to refer to it some other way than it's real name. (That is where I was
going with "mod1name".)

So, is there a way to activate a window using a variable name? (I know you
can open a file using a variable name.)

Thanks in advance.

-Chris
 
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
Excel files in separate program windows Jason Dove Excel Discussion (Misc queries) 27 October 24th 08 07:58 PM
COUNTIF MULTIPLE CRITERIA will A Excel Discussion (Misc queries) 18 March 8th 06 06:58 PM
How to resize Data Form dialog window? Compucat Excel Worksheet Functions 1 June 8th 05 11:24 PM
How do I reset default Excel window too view=fullscreen needyourhelp Setting up and Configuration of Excel 4 March 7th 05 10:37 PM
Help resizes window &%$#! Oskar von dem Hagen Excel Discussion (Misc queries) 0 February 26th 05 01:09 AM


All times are GMT +1. The time now is 12:19 AM.

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"