Is this the way to run a automarco??

Drumaster

New Member
Joined
Feb 28, 2011
Messages
25
Hi all,

If the file AlarmLog.xls is opent i wanna run a marco

I try this .... but nothing
Code:
Private Sub Workbook_Activate()
  If ActiveWorkbook.Name = "AlarmLog.xls" Then
  expression.RunAutoMacros (Alarms_barChart)
  End If
End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Where have you put that macro exactly?

In the personal work map before the marco Alarms_barChart


Code:
Private Sub Workbook_Activate()  
If ActiveWorkbook.Name = "AlarmLog.xls" Then  
expression.RunAutoMacros (Alarms_barChart)  
End If
End Sub
 
Sub Alarms_barChart()
' Alarms_barChart Macro
' only use with DBF file
' Sneltoets: Ctrl+ J
    '**** Create folder if not  ****
Dim Map
Dim fol  As String
fol = "D:\Colpitt machine data" ' change to match the folder path
Set Map = CreateObject("Scripting.FileSystemObject")
If Not Map.FolderExists(fol) Then
    Map.CreateFolder (fol)
End If
 
    Range("K2").Select
    Range("K2,K:K").FormulaR1C1 = "=IF(RC[-3]-RC[-4]<=0,,RC[-3]-RC[-4])"
    Range("K:K").NumberFormat = "h:mm:ss;@"
.......
...
....
......
 End Sub
 
Upvote 0
Er, I don't understand this ... "In the personal work map"?!?!?
 
Upvote 0
Er, I don't understand this ... "In the personal work map"?!?!?

you have the choice between to save your marco in your workbook or personalbook.

if I save it in that workbook I can only use the marco in that workbook.
Personalbook i can use it in every excel book i open

(i'm still a noob with this maybe i have it wrong )
 
Upvote 0
But you have a test for the workbook name being a specific workbook ... so it is not going to work for every workbook, even if it did fire during an activate event ( which it won't, the way you have things now ).
 
Upvote 0

Forum statistics

Threads
1,214,858
Messages
6,121,960
Members
449,057
Latest member
FreeCricketId

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