+ Reply to Thread
Results 1 to 4 of 4

How can I refer to the ActiveWindow

  1. #1
    Registered User
    Join Date
    06-23-2006
    Posts
    34

    How can I refer to the ActiveWindow

    I my macro I improt data by opening a spreadsheet copying the data over and closing it, and therefore flick between workbooks.

    This is creating my problems and flicks to the wrong workbooks occasionally.

    So I need to tell it to flick back the workbook the marco is in, but this workbook changes its name, so I can not say:

    Windows(".......").Activate

    Is there a way I can at the beginning give the workbook a name reference early on in the macro, eg something like:

    MacroWorkbook = ActiveWindow

    ? And then each time I want to flick to this workbook I can refer to it as:

    Windows(MacroWookbook).Activate?

    Thanks

  2. #2
    Zone
    Guest

    Re: How can I refer to the ActiveWindow

    ThisWorkbook.Activate
    will always activate the workbook in which the macro is located. Is
    there a problem with using this?
    James

    CarolineHedges wrote:
    > I my macro I improt data by opening a spreadsheet copying the data over
    > and closing it, and therefore flick between workbooks.
    >
    > This is creating my problems and flicks to the wrong workbooks
    > occasionally.
    >
    > So I need to tell it to flick back the workbook the marco is in, but
    > this workbook changes its name, so I can not say:
    >
    > Windows(".......").Activate
    >
    > Is there a way I can at the beginning give the workbook a name
    > reference early on in the macro, eg something like:
    >
    > MacroWorkbook = ActiveWindow
    >
    > ? And then each time I want to flick to this workbook I can refer to it
    > as:
    >
    > Windows(MacroWookbook).Activate?
    >
    > Thanks
    >
    >
    > --
    > CarolineHedges
    > ------------------------------------------------------------------------
    > CarolineHedges's Profile: http://www.excelforum.com/member.php...o&userid=35705
    > View this thread: http://www.excelforum.com/showthread...hreadid=558831



  3. #3
    Stefi
    Guest

    RE: How can I refer to the ActiveWindow

    Try

    ThisWorkbook.Activate

    Regards,
    Stefi


    „CarolineHedges” ezt *rta:

    >
    > I my macro I improt data by opening a spreadsheet copying the data over
    > and closing it, and therefore flick between workbooks.
    >
    > This is creating my problems and flicks to the wrong workbooks
    > occasionally.
    >
    > So I need to tell it to flick back the workbook the marco is in, but
    > this workbook changes its name, so I can not say:
    >
    > Windows(".......").Activate
    >
    > Is there a way I can at the beginning give the workbook a name
    > reference early on in the macro, eg something like:
    >
    > MacroWorkbook = ActiveWindow
    >
    > ? And then each time I want to flick to this workbook I can refer to it
    > as:
    >
    > Windows(MacroWookbook).Activate?
    >
    > Thanks
    >
    >
    > --
    > CarolineHedges
    > ------------------------------------------------------------------------
    > CarolineHedges's Profile: http://www.excelforum.com/member.php...o&userid=35705
    > View this thread: http://www.excelforum.com/showthread...hreadid=558831
    >
    >


  4. #4
    Registered User
    Join Date
    06-23-2006
    Posts
    34
    I knew there must be a really simple way, but I just didn't know what it was.

    Thank you

+ 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