SHARE
Facebook X Pinterest WhatsApp

Get Friend File

Macro that opens the corresponding .h / .cpp file (i.e. if fnurt.h is active it opens fnurt.cpp and vice verca) and works best if used via a accelerator key (using Alt-1 myself). Quite lo-tech but useful never the less. Sub GetFriendFile() ‘DESCRIPTION: Opens the corresponding .h / .cpp file currentFileName = Application.ActiveDocument.FullName newFileName = “” […]

Written By
thumbnail
CodeGuru Staff
CodeGuru Staff
Feb 2, 1999
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Macro that opens the corresponding .h / .cpp file (i.e. if fnurt.h is active it opens fnurt.cpp and vice verca)
and works best if used via a accelerator key (using Alt-1 myself).

Quite lo-tech but useful never the less.

Sub GetFriendFile()
‘DESCRIPTION: Opens the corresponding .h / .cpp file
 currentFileName = Application.ActiveDocument.FullName
 newFileName = “”
 if (Ucase(Right(currentFileName,2))=”.H”) then
   newFileName = Left(currentFileName,Len(currentFileName)-2)+”.CPP”
 elseif (Ucase(Right(currentFileName,4))=”.CPP”) then
   newFileName = Left(currentFileName,Len(currentFileName)-4)+”.H”
 end if
 if newFileName<>“” then Application.Documents.Open newFileName
End Sub

Date Last Updated: February 3, 1999

Recommended for you...

Top Plugins for Visual Studio
Enrique Stone
Feb 3, 2023
Developer News Is Coming Back to Visual Studio
Hannes DuPreez
Jan 24, 2023
GitHub Copilot Overview
Hannes DuPreez
Aug 6, 2022
Visual Studio 2022 for Mac Released
Hannes DuPreez
Jun 20, 2022
CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.