Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / September 2004

Tip: Looking for answers? Try searching our database.

Best way to open a document in VS.Net extensibility

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mark Sisson - 03 Sep 2004 15:43 GMT
********* <USING VS.NET 2005 BETA 1> ************

Is the code below the only way to open a document in VS.NET? Am I
missing something like
DTE.Solutions.Projects["MyProject"].Files["Class1.cs"].Activate();????

---------------------------------
DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()

DTE.ActiveWindow.Object.GetItem("MyAddin1\MyAddin1\Class1.cs").Select(vsUISelectionType.vsUISelectionTypeSelect)

DTE.ActiveWindow.Object.DoDefaultAction

DTE.Windows.Item("Class1.cs").Activate
---------------------------------

THANKS
Mark
Emil Astrom - 04 Sep 2004 22:59 GMT
Here's an alternative that works without requiring the file to be in the
project:

DTE.ExecuteCommand("File.OpenFile", sFilename)

Maybe there are better ways, but this works for me.

/Emil

> ********* <USING VS.NET 2005 BETA 1> ************
>
[quoted text clipped - 4 lines]
> ---------------------------------
> DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()

DTE.ActiveWindow.Object.GetItem("MyAddin1\MyAddin1\Class1.cs").Select(vsUISe
lectionType.vsUISelectionTypeSelect)

> DTE.ActiveWindow.Object.DoDefaultAction
>
[quoted text clipped - 3 lines]
> THANKS
> Mark
Emil Astrom - 06 Sep 2004 18:53 GMT
One more thing: The filename should be surrounded with quotes ("), otherwise
you'll get into trouble with paths containing spaces. So maybe a better code
example would be the following:

DTE.ExecuteCommand("File.OpenFile", """" + sFilename + """")

Cheers,

Emil

> Here's an alternative that works without requiring the file to be in the
> project:
[quoted text clipped - 13 lines]
> > ---------------------------------
> > DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()

DTE.ActiveWindow.Object.GetItem("MyAddin1\MyAddin1\Class1.cs").Select(vsUISe
> lectionType.vsUISelectionTypeSelect)
> >
[quoted text clipped - 5 lines]
> > THANKS
> > Mark
Cyril Mathey - 07 Sep 2004 20:03 GMT
Hello Mark & Emil,

Executing the File.OpenFile command works but it actually shows the editor.
If you only intend to open the document to modify it without any feedback
from the UI,
you shoud use the ProjectItem class:

EnvDTE.ProjectItem item = DTE.Solution.FindProjectItem(fileName);
item.Open(EnvDTE.Constants.vsViewKindAny);

Hope this helps.

--
Cyril

> Here's an alternative that works without requiring the file to be in the
> project:
[quoted text clipped - 24 lines]
>> THANKS
>> Mark

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.