Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Reorder Resource ID Macro

0.00/5 (No votes)
10 Aug 2001 1  
This simple macro helps to Reorder Resource ID in resource.h

Introduction

Visual C++ project contains a symbol definition file - named "resource.h" which contains #define directives for each of the symbols used in the project. When you copy some resource from another project to your work project, you may get dup resource id definition - two symbols have the same value.

I wrote this simple macro to reorder the Resource ID in 5 minutes, it works for me. I hope you will find it useful as well.

The Macro Code

Sub ReorderResource()
	Dim objTheDocument
	Dim sSelectedText
	set objTheDocument = ActiveDocument
	Dim nNumber
	Dim nCount
	nCount=1
	if objTheDocument.Name <> "resource.h" then
		MsgBox "This macro only working for resource.h"
		exit sub
	end if
	objTheDocument.Selection.StartOfDocument
	objTheDocument.Selection.FindText ("#define")
	Do
		objTheDocument.Selection.StartOfLine
		objTheDocument.Selection.WordRight dsExtend
		objTheDocument.Selection.WordRight dsExtend
		if objTheDocument.Selection.Text <> "#define " then
			exit do
		end if
		objTheDocument.Selection.EndOfLine
		objTheDocument.Selection.WordLeft dsExtend
		nNumber = int(objTheDocument.Selection.Text)
		if nCount < nNumber then
			nCount = nNumber
		end if
		objTheDocument.Selection.Text = "" & nCount
		nCount = nCount + 1
		objTheDocument.Selection.LineDown
	Loop
End Sub

History

  • 10th August, 2001: Initial post

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here