Macro To Switch Between Header and Cpp File

CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

This is a simple macro to allow you to switch between the header and cpp
file.

Sub Jump()
‘////////////////////////////////////////////
‘Nooruddin Kapasi 1998.
‘DESCRIPTION: Switch Between Header and cpp
‘////////////////////////////////////////////
Dim myDocument
Dim a
Dim b
Dim Flag
Dim Flag1
Flag1 = 0
Flag = 1
a = ActiveDocument.FullName
tmp = InStr(a, “.cpp”)
If tmp Then
b = Left(a, Len(a) – 3) + “h”
Flag1 = 1
Else
tmp = InStr(a, “.h”)
If tmp Then
b = Left(a, Len(a) – 1) + “cpp”
Flag1 = 1
End If
End If
For Each myDocument In Application.Documents
If myDocument.FullName = b Then
myDocument.Active = True
Flag = 0
Exit For
End If
Next
If Flag And Flag1 Then
Documents.Open b, “Text”
End If
End Sub

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read