Click here to Skip to main content
15,915,600 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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
VB
dim wb as Excel.Workbook

even if there is no imports statement.
Posted
Comments
Maciej Los 22-Sep-15 15:24pm    
Compiler can understand Excel.Workbook as long as reference to Interop library is active ;)
General Reference (Office Development in Visual Studio)
ExcelinEfendisi 22-Sep-15 17:20pm    
but, shouldn't be there a code like "Imports Excel=ms.off.interop.excel"
i cannot see any code like this.
Sergey Alexandrovich Kryukov 22-Sep-15 21:25pm    
The problem is not that you don't see something, the problem that you don't show us what you see.
—SA
ExcelinEfendisi 23-Sep-15 9:47am    
well, all the sample codes on the net include the code line "Imports Excel=ms.off.interop.excel", which makes "Excel" an alias for the interop namesapce.
but when start a project from scratch, even though i, myself, don't put a code like this and don't see it in any other file in the project, i am able to use the alias. what i am asking is how come this is possible? Is "Excel" default alias or something for the interop namespace?
Sergey Alexandrovich Kryukov 23-Sep-15 10:34am    
There are two forms of "Imports" (which, by the way, doesn't "import" anything, it just changes the default naming of assembly-level types), alias and regular, non-alias...
—SA

1 solution

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 :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900