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.
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,302
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
76,302
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
76,302
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
76,302
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.
 

Forum statistics

Threads
1,140,916
Messages
5,703,161
Members
421,278
Latest member
16cwilliams

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top