Load text file into Excel and run a macro

AlexanderBB

Well-known Member
Joined
Jul 1, 2009
Messages
1,835
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
Hi, I'm trying to load a text file into Word 2007 and automatically run a macro. I'm using Powertoys SendTo on my text file to "C:\Program Files\Microsoft Office\Office12\EXCEL.EXE" E:\Test\Resource.xlsm
I'm nearly there but what I find is the text file becomes a second VBA Project and Workbook Open executes before the text file has loaded. I want it to execute after its loaded.

I was given this for the Workbook Open module but it's not working as hoped.

Code:
Public Sub Workbook_Open_Delayed()
MsgBox ActiveSheet.Name
Stop
End Sub
Private Sub Workbook_Activate()
  Static OpenHasRun As Boolean
  If Not OpenHasRun Then
    Workbook_Open_Delayed
    OpenHasRun = True
  End If
End Sub


Any help appreciated,
Thanks, ABB
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,214,534
Messages
6,120,084
Members
448,943
Latest member
sharmarick

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
Back
Top