Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

activation of dynamic named workbook

Status
Not open for further replies.

kiwieur

Technical User
Apr 25, 2006
200
GB
Hi,

I am using the following code to copy a sheet from one workbook to another.

Code:
Private Sub cmdAppend_Click()
    Workbooks.Open Filename:="D:\PaulsDocuments\Business\Customers\Rigid\OTIF\Data.xls"
    Sheets("Sheet1").Visible = True
    Sheets("tblData").Select
    Application.DisplayAlerts = False
    ActiveWindow.SelectedSheets.Delete
    Application.DisplayAlerts = True
    [b][COLOR=red]Windows("Oct08.xls").Activate[/color][/b]
    Sheets("tblData").Select
    Sheets("tbldata").Copy _
    After:=Workbooks("Data.xls").Worksheets(Workbooks("Data.xls").Worksheets.Count)
    Columns("N:N").Select
    Selection.Delete Shift:=xlToLeft
    ActiveSheet.Shapes("cmdCall").Select
    Selection.Delete
    Range("A2").Select
    Sheets("Sheet1").Select
    ActiveWindow.SelectedSheets.Visible = False
    Workbooks("Data.xls").Save
    Workbooks("Data.xls").Close
    Range("A2").Select
    frmMacros.Hide
End Sub

The name of the workbook highlighted in red is the workbook where the code is being run from and each month the name of the workbook will change i.e.

Oct08.xls
Nov08.xls
Dec08.xls

I would like to replace

Code:
Windows("Oct08.xls").Activate
with some kind of dynamic code that will get the current name of the workbook and put it in the quotes.

i.e. something like
Code:
Windows("WorkbookName").Activate

is this possible ??


Regards

Paul

 
Hi,

It's OK I'm having a bad day, i just realised that as I am running the code from the workbook all i need to use is

Code:
ThisWorkbook.Activate



Regards

Paul

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top