LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

macro LabVIEW other file

Hi everyone,

 

I would like to use a macro in every .XLS file that LabVIEW will open. The macro is in a .XLSM file.

How to make it on LabVIEW ??

 

Here is my macro:

Sub Incrémental()
Dim Sh As Worksheet
Dim Ch As Chart
Dim i As Integer
 
Application.ScreenUpdating = False
On Error Resume Next
Application.DisplayAlerts = False
Sheets("Graph").Delete
Application.DisplayAlerts = True
On Error GoTo 0
 
Set Sh = ThisWorkbook.Worksheets(1)
Set Ch = ThisWorkbook.Charts.Add(After:=ThisWorkbook.Worksheets(1))
With Ch
    For i = .SeriesCollection.Count To 1 Step -1
        .SeriesCollection(i).Delete
    Next i
    .Name = "Graph"
    .ChartType = xlXYScatterSmoothNoMarkers
    .SeriesCollection.NewSeries
    With .SeriesCollection(1)
        .Name = "T° Sample (°C)"
        .XValues = Sh.Range("A:A")
        .Values = Sh.Range("B:B")
    End With
    .SeriesCollection.NewSeries
    With .SeriesCollection(2)
        .Name = "T° Contact (°C)"
        .XValues = Sh.Range("A:A")
        .Values = Sh.Range("C:C")
    End With
    .SeriesCollection.NewSeries
    With .SeriesCollection(3)
        .Name = "Torque (N.m)"
        .XValues = Sh.Range("A:A")
        .Values = Sh.Range("I:I")
    End With
    With .SeriesCollection(1)
    .AxisGroup = 2
    End With
    .HasTitle = True
    .ChartTitle.Characters.Text = Sh.Name
    With .Axes(xlCategory, xlPrimary)
        .HasTitle = True
        .AxisTitle.Characters.Text = "Time (s)"
    End With
    With .Axes(xlValue, xlPrimary)
        .HasTitle = True
        .AxisTitle.Characters.Text = "Torque (N.m)"
    End With
    With .Axes(xlValue, xlSecondary)
        .HasTitle = True
        .AxisTitle.Characters.Text = "Temperature (°C)"
    End With
End With
Set Sh = Nothing
Set Ch = Nothing
End Sub

 

<script type="text/javascript">// (function(){var src=document.getElementById('source');src.focus();src.select();src.style.boxSizing=src.style.WebkitBoxSizing=src.style.MozBoxSizing=src.style.MsBoxSizing='border-box';})(); // </script>

And you can find my Vi, jpeg format, attached.
Thanks for your help which will be invaluable to me.
Devour

0 Kudos
Message 1 of 2
(4,897 Views)
0 Kudos
Message 2 of 2
(4,875 Views)