Sub FileSwitch()
Try
Dim CurrentPath As String = DTE.ActiveDocument.FullName
Dim OtherPath As String
If (IO.Path.HasExtension(CurrentPath)) Then
Dim CurrentExtension As String = IO.Path.GetExtension(CurrentPath)
Select Case CurrentExtension
Case ".h", ".hpp", ".hxx"
OtherPath = IO.Path.ChangeExtension(CurrentPath, ".cpp")
If (Not IO.File.Exists(OtherPath)) Then
OtherPath = IO.Path.ChangeExtension(CurrentPath, ".c")
If (Not IO.File.Exists(OtherPath)) Then
OtherPath = IO.Path.ChangeExtension(CurrentPath, ".cxx")
End If
End If
Case ".cpp", ".c", ".cxx"
OtherPath = IO.Path.ChangeExtension(CurrentPath, ".h")
If (Not IO.File.Exists(OtherPath)) Then
OtherPath = IO.Path.ChangeExtension(CurrentPath, ".hpp")
If (Not IO.File.Exists(OtherPath)) Then
OtherPath = IO.Path.ChangeExtension(CurrentPath, ".hxx")
End If
End If
Case Else
End Select
If (OtherPath <> Nothing) Then
DTE.ItemOperations.OpenFile(OtherPath)
End If
End If
Catch ex As System.Exception
MsgBox(ex.Message)
End Try
End Sub
I don't see this answer here, but at least in Visual Studio 2012 (Express included!), you can just assign your own keyboard command to go to the header file (NOTE: Only goes one way -- you can't go back to the source file unfortunately...)