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

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.

Drumaster

New Member
Joined
Feb 28, 2011
Messages
25
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
 

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,547
Er, I don't understand this ... "In the personal work map"?!?!?
 

Drumaster

New Member
Joined
Feb 28, 2011
Messages
25
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 )
 

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,547
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 ).
 

Watch MrExcel Video

Forum statistics

Threads
1,130,448
Messages
5,642,218
Members
417,262
Latest member
andrewd1

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