Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Not able to run VB Script from Alteryx, but running in Excel

Parthasarathi
8 - Asteroid

Hi All,

 

I am trying the below vb script to copy required columns data from a sheet to another existing sheet in the same workbook. I am executing this .vbs file using Run Command component, but 

 

Sub foo1()
Dim src As Worksheet
Dim trg As Worksheet
Dim LastRow As Long

Set src=ThisWorkbook.Worksheets("Summary")
Set trg = ThisWorkbook.Worksheets("Sheet1")

src.Range("D:D").Copy Destination:=trg.Range("A1")
src.Range("E:E").Copy Destination:=trg.Range("B1")
src.Range("F:F").Copy Destination:=trg.Range("C1")
src.Range("G:G").Copy Destination:=trg.Range("D1")
End Sub

 

Getting error like below:

Parthasarathi_0-1662977719200.png

 

But the same script working in excel under developer menu. But not from Alteryx. Please help, thanks in advance

 

5 REPLIES 5
dYoast
11 - Bolide

@Parthasarathi 

 

When you run the script in Excel, it knows the object to perform its tasks on.

 

When you try to run it independently, it has no idea of the object it is supposed to work with.

You would need to add to the script to declare the object Excel and to open the object.

Parthasarathi
8 - Asteroid

@dYoast,

 

Could you please share me the script to run it from the Alteryx

Luke_C
17 - Castor

Hi @Parthasarathi 

 

Here's an example where I used a vbs file triggered by Alteryx to run a macro within a workbook. You can adapt to your needs. Hope this helps.

 

In the below example, the 'file path' is populated dynamically by the workflow. 

 

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\File Path")
objExcel.Application.DisplayAlerts = False
objExcel.Application.Visible = False
objWorkbook.Application.Run "MacroName"
objExcel.ActiveWorkbook.Save
objExcel.ActiveWorkbook.Close

 

Parthasarathi
8 - Asteroid

@Luke_C,

 

Could you please share a sample workflow calling this VBS, still I am facing issue to pass the filename as argument to the Run Command component.

Labels