Hello,
I have some problem with the following code:
EnvDTE.Document doc = item.Document;
// EnvDTE.CodeElements els = doc.ProjectItem.FileCodeModel.CodeElements;
EnvDTE.CodeElements els = item.FileCodeModel.CodeElements;
either way my FileCodeModel is null, since my Document is not the active document. Now my question is, if anybody knows, if it would be possible to get the code element even it is not set to active document.
Best Regards,
Hasan

Is it possible to get the CodeElement of a projectItem, when the item is not the active document?
OffThaTop
For your purpose, EnvDTE.Constants.vsext_vk_Code
Notice that there are other vsext_vk_XXX constants for other views.
--
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
Prajkta
Thank you very much Carlos, but i still have a question, i did not really get the "view" parameter this method expects. Its a string type parameter, what should i pass in this string
Best Regards,
Ranju Akram
signy
Hi,
You first need to guess if the projectitem has an open window via ProjectItem.IsOpen(view), and if not, open a window with ProjectItem.Open(view), which does not mean to make the window visible (for that you would need to call window.Visible=true). Then, retrieve the filecodemodel and when done close the window if it was not open.
--
Best regards,
Carlos J. Quintero
MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com