+ Reply to Thread
Results 1 to 2 of 2

Reference current file open in macro

  1. #1
    Registered User
    Join Date
    01-25-2005
    Posts
    1

    Reference current file open in macro

    I need some help creating a macro that would
    Open another file copy data from there then go back and paste the data in the template file, but work with the template as a different filename (whichever one is open).
    Is there a way to reference the current open file?

    This is what I have so far.

    Workbooks.Open Filename:="\\server\public\name\DATA.xls"
    Range("B3:AC21").Select
    ActiveWindow.SelectedSheets.PrintPreview
    Selection.Copy
    Windows("template.xls").Activate
    Range("Z5").Select
    ActiveSheet.Paste
    Windows("DATA.xls").Close

    Any help would be appreciated.

    Thank You,

    Steve

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258
    Hello s_rjohnson,

    You can return the path of a workbook using the following...

    Workbooks("Workbook1").Path (The Path does not include the Workbook name)

    This also works with ActiveWorkbook...

    WbkPath = ActiveWorkbook.Path

    WbkName = ActiveWorkbook.Name

    Hope this helps,
    Leith Ross

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1