ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Soft-coding document name? (https://www.excelbanter.com/excel-discussion-misc-queries/90938-soft-coding-document-name.html)

Rick Charnes

Soft-coding document name?
 
We have the following line in an Excel macro

Windows("May 06 Outlook - prelim.xls").Activate

I believe the macro is attached to the document "May 06 Outlook -
prelim.xls". Next month this doc will be modified and renamed to "June
07 - prelim.xls". Is there a way to soft-code the document name (into a
variable?) here so that every time this macro is run the variable
expands to the doc name?

Bob Phillips

Soft-coding document name?
 
Surely, if that code is in the workbook, when you open it it will already
be active, so the code is unnecessary?

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"Rick Charnes" wrote in message
om...
We have the following line in an Excel macro

Windows("May 06 Outlook - prelim.xls").Activate

I believe the macro is attached to the document "May 06 Outlook -
prelim.xls". Next month this doc will be modified and renamed to "June
07 - prelim.xls". Is there a way to soft-code the document name (into a
variable?) here so that every time this macro is run the variable
expands to the doc name?




Ardus Petus

Soft-coding document name?
 
Windows(format(Date,"mmmm yy") & " Outlook - prelim.xls").Activate

HTH
--
AP

"Rick Charnes" a écrit dans le
message de news: ...
We have the following line in an Excel macro

Windows("May 06 Outlook - prelim.xls").Activate

I believe the macro is attached to the document "May 06 Outlook -
prelim.xls". Next month this doc will be modified and renamed to "June
07 - prelim.xls". Is there a way to soft-code the document name (into a
variable?) here so that every time this macro is run the variable
expands to the doc name?




Dave Peterson

Soft-coding document name?
 
Does this mean that the line of code is in the workbook named:
"May 06 Outlook - prelim.xls"

If yes, you can use:
Thisworkbook.activate





Rick Charnes wrote:

We have the following line in an Excel macro

Windows("May 06 Outlook - prelim.xls").Activate

I believe the macro is attached to the document "May 06 Outlook -
prelim.xls". Next month this doc will be modified and renamed to "June
07 - prelim.xls". Is there a way to soft-code the document name (into a
variable?) here so that every time this macro is run the variable
expands to the doc name?


--

Dave Peterson


All times are GMT +1. The time now is 01:29 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com