Running vb script in windows on open spreadsheet

stu1811

New Member
Joined
Oct 19, 2006
Messages
28
Everyday I get an email with a spreadsheet. Instead of pasting in my vb code into the macro editor, I want run a vb script from windows on the spreadsheet. Since the spreadsheet's name changes with the date, I thought it would be easiest to look for an active excel window. Any other suggestions are welcome.
 

Some videos you may like

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,919
Office Version
  1. 365
Platform
  1. Windows
Why can't you just run the code from Excel?

You could have a workbook that only contains the code.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,919
Office Version
  1. 365
Platform
  1. Windows
Just put the code in a workbook and run it.

Code can refer to other worksheets/workbooks.
 

stu1811

New Member
Joined
Oct 19, 2006
Messages
28

ADVERTISEMENT

How do I run code from another workbook? It doesnt show up as an option when I goto run macro
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,919
Office Version
  1. 365
Platform
  1. Windows
I think you need to explain further exactly what you want to do.

Maybe I'm missing something.:eek:

What I'm suggesting is to have a workbook with the code in it.

The code in that workbook would be used to open the other workbook and then do whatever it is you want to do to it.
 

stu1811

New Member
Joined
Oct 19, 2006
Messages
28

ADVERTISEMENT

I want to open an excel file and run a macro.
The tricky part: The file name changes daily and each sheet is its own workgroup.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,919
Office Version
  1. 365
Platform
  1. Windows
Well you could do this from another workbook.

But do give specific advice would require more information.

Where is the workbook located?

How does the name change?
 

stu1811

New Member
Joined
Oct 19, 2006
Messages
28
The date is part of the file name. All of the files are located in the same folder.
 

Watch MrExcel Video

Forum statistics

Threads
1,114,096
Messages
5,545,926
Members
410,713
Latest member
TaremyLunsil
Top