这是我的 aspx/aspx.cs 翻转器的宏源。它在 2005 年有效,但在 08 年可能会出现问题。我不确定...这是从我的其他 cpp/h 脚蹼中获取的,因此可能需要进行一些清理以使其达到最佳状态。我编写宏没有报酬,所以当我需要宏时,我必须尽快完成它们。
Sub OpenASPOrCS()
'DESCRIPTION: Open .aspx file if in .cs file, open .cs file if in .aspx file
On Error Resume Next
' Get current doc path
Dim FullName
FullName = LCase(ActiveDocument.FullName)
If FullName = "" Then
MsgBox("Error, not a .cs or asp file!")
Exit Sub
End If
' Get current doc name
Dim DocName
DocName = ActiveDocument.Name
Dim IsCSFile
IsCSFile = False
Dim fn
Dim dn
If (Right(FullName, 3) = ".cs") Then
fn = Left(FullName, Len(FullName) - 3)
dn = Left(DocName, Len(DocName) - 3)
IsCSFile = True
ElseIf ((Right(FullName, 5) = ".aspx") Or (Right(FullName, 5) = ".ascx")) Then
fn = FullName + ".cs"
dn = DocName + ".cs"
Else
MsgBox("Error, not a .cs, or an asp file!")
Exit Sub
End If
Dim doc As EnvDTE.Documents
DTE.ItemOperations.OpenFile(fn)
doc.DTE.ItemOperations.OpenFile(fn)
If Err.Number = 0 Then
Exit Sub
End If
' First check to see if the file is already open and activate it
For Each doc In DTE.Documents()
If doc.Name = dn Then
doc.Active = True
Exit Sub
End If
Next
End Sub