Code Definition

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rshin2020
    New Member
    • Dec 2009
    • 26

    Code Definition

    Hi. Below here i have a piece of code. I don't understand the exact meaning of the Type.Missing here. What's its use for?

    Code:
    objBook.SaveAs("Report Uncertainty.xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlShared, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
    Thanks in advance.
  • Sl1ver
    New Member
    • Mar 2009
    • 196

    #2
    Im not 100% sure but .SaveAs take overload methods, these values get passed to the .SaveAs method but if there isn't any data to pass Type.Missing is entered

    if ur using visual studio and you type objBook.SaveAs( , when you get to the ( part,then it will actually show you what should go there.

    do u understand what i mean?

    Comment

    • dennisoleksyuk
      New Member
      • Jan 2010
      • 17

      #3
      Placeholder for Optional parameters in C#

      You probably work with the Interop for the MS Excel automation library.

      All parameters of Workbook.SaveAs method are optional with some predefined default values. But C# does not support optional parameters. Type.Missing serves in such situation as a placeholder for a optional parameter when you call method from C#. Interop library will replace Type.Missing values with default values for those parameter.

      Comment

      • rshin2020
        New Member
        • Dec 2009
        • 26

        #4
        So in other words, from what i understand, that it just sets a default if no other exact values are entered? Am I right?

        Comment

        • Sl1ver
          New Member
          • Mar 2009
          • 196

          #5
          thats is exactly what i mean

          Comment

          • rshin2020
            New Member
            • Dec 2009
            • 26

            #6
            Alright. Thank you very much for your explanation.

            Comment

            Working...