From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Conditional Formatting in MS Excel using Scipt

Hi,

I have written a script which writes Channel Values to an Excel File.

After writng values to Excel, the below script executes which saves the file to a different path.

If I press 'YES' the file is saved or asks to overwrite. But If I click 'NO' an Option appears on Excel to save the file.I want to remove this Dialog in Excel .

 

Dim RawGroup,RawChannels,myExcelApp,j,myWorksheet,myRange,Excel
  Call GroupDefaultSet(28)
  Set myExcelApp = CreateObject("Excel.Application")
  myExcelApp.Visible = TRUE
  Set myWorksheet=myExcelApp.Workbooks.Open("FilePath
  Set myWorksheet = myExcelApp.Activesheet

 

  If MsgBox("Save Excel?", vbYesNo Or vbQuestion, "Bestätigen") = vbYes Then
     myWorksheet.Parent.Saved = True
    ' Call myExcelApp.ActiveSheet.Parent.SaveAs("FilePath")
    Call myWorksheet.SaveAs("SaveFilePath")
'      myExcelApp.close
      myExcelApp.Quit
    Else myWorksheet.Parent.Saved = False
'    myWorksheet.quit
'    myExcelApp.close    
    myExcelApp.Quit
  End If
 

 

Next, I want to use conditional Formatting in Excel using DIAdem script function. Can it be done?

 

 

Have A Great Day

Himanshu Sharma

 

 

0 Kudos
Message 1 of 3
(2,191 Views)

Hey Himanshu,

 

           Consider adding this to your script:

 

 ExcelApp.DisplayAlerts=false

 ExcelApp.Close false

 

           It should remove any kind of prompts and save options. It works for me quite well.

 

          Also I think that you could do conditional formatting as well - depending on what you want to achieve. Check this link and see if it works out for you - it might give you some hints:

 

          https://stackoverflow.com/questions/13661965/conditional-formatting-using-excel-vba-code

       

Sincerely yours,

Denis

0 Kudos
Message 2 of 3
(2,074 Views)

Thanks Denis

0 Kudos
Message 3 of 3
(2,068 Views)