locked
vsto namespace interop RRS feed

  • Question

  • Hi,

    this is a question just asked out of curiosity.  if someone could clarify, that'd be appreciated.

    i just wonder how the compiler understands that what is implied is microsoft.office.interop.excel namespace when we write somthing like this
    dim wb as Excel.Workbook
    even if there is no imports statement.

    Dig your well before you are thirsty

    Tuesday, September 22, 2015 6:46 PM

Answers

  • i think i found the answer. in the properties >references, there is a section called Imported Namespaces, i found the 

    Imports Excel =  microsoft.office.interop.excel 

    statement over there. so, VS does this job automaticallay for us, which is cool :)


    Dig your well before you are thirsty

    Wednesday, September 23, 2015 3:47 PM

All replies

  • Hi,

    If there is no imports statement, there would be an compile error for the code above. To run the code above successful, we need to import the namespace with an aliasname like code below. 

    Imports Excel =  microsoft.office.interop.excel 
    

    We can use the Office PIAs assembly like common managed assembly. You can get more detail about Imports Statement from link below:
    https://msdn.microsoft.com/en-us/library/7f38zh8x.aspx?f=255&MSPPError=-2147217396

    And here is an helpful link for your learning developing with VB:
    Developing Applications with Visual Basic

    Hope it is helpful.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, September 23, 2015 2:55 AM
  • Excel is an alias for the Microsoft.Office.Interop.Excel namespace. See Imports Statement (.NET Namespace and Type) for more information in MSDN.
    Wednesday, September 23, 2015 6:15 AM
  • hi fei,

    but when i first create a project from the scratch, i am able to write a code line like above without importing any namespace. i seacrhed all the hidden files, anc couldnt find any import line, neither with alias nor without.


    Dig your well before you are thirsty

    Wednesday, September 23, 2015 1:34 PM
  • Eugene, is it a default alias or somenthig?

    shouldn't you state it this way?

    Imports Excel =  microsoft.office.interop.excel 


    Dig your well before you are thirsty

    Wednesday, September 23, 2015 1:36 PM
  • i think i found the answer. in the properties >references, there is a section called Imported Namespaces, i found the 

    Imports Excel =  microsoft.office.interop.excel 

    statement over there. so, VS does this job automaticallay for us, which is cool :)


    Dig your well before you are thirsty

    Wednesday, September 23, 2015 3:47 PM