0

I want to run a macro through a PowerShell script. I figured out how to start the macro.

$ExcelPath = "R:\01.DS\04.X-DS\13. Proposed plan\Proposed_plan_WINGS.xlsm"
$Excel = New-Object -ComObject Excel.Application
$Excel.Visible = $true
$Workbook = $Excel.Workbooks.Open($ExcelPath)
$Worksheets = $Workbooks.Worksheets
$Worksheet = $Workbook.Worksheets.Item(1)

$Excel.Run('Iris_prop_plan')

However, when the macro starts, a popup appears which says: update values. How do I include this in the code?

5
  • Possible duplicate of Prevent the “Update Values:” dialog box from opening every time a cell with a link is modified. Commented Sep 7, 2017 at 9:32
  • Hi, this does not work for me. Commented Sep 7, 2017 at 10:43
  • this does not work for me is a little vague. There were 3 suggestions in that linked post. You tried all of them and it changed nothing and you still get the problem? If it didnt help I would add what you specifically tried as an edit to the question. Commented Sep 7, 2017 at 11:32
  • Hi, "displayalerts is false" stops showing the popupbox, but the macro is leaving out key steps linked with adding the values. "xlUpdateLinksNever" is not recognized as a command in powershell. Commented Sep 7, 2017 at 13:33
  • 1
    [Microsoft.Office.Interop.Excel.Constants]::xlUpdateLinksNever. Aside from that I doubt we can do anything else without knowing the code of your macro. Commented Sep 7, 2017 at 13:43

1 Answer 1

1
# start Excel
$excel = New-Object -comobject Excel.Application
#open file
$FilePath = 'FilePath'
$workbook = $excel.Workbooks.Open($FilePath)
##If you will like to check what is happend
$excel.Visible = $true
## Here you can "click" the button
$app = $excel.Application
$app.Run("MacroName")

       ##The macro name is the trigger of your button
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.