65.9K
CodeProject is changing. Read more.
Home

Reorder Resource ID Macro

starIconstarIconstarIconemptyStarIconemptyStarIcon

3.00/5 (2 votes)

Aug 11, 2001

CPOL
viewsIcon

49472

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