Click here to Skip to main content
Click here to Skip to main content
Go to top

Reorder Resource ID Macro

, 10 Aug 2001
Rate this:
Please Sign up or sign in to vote.
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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Roy Luo
Web Developer
China China
No Biography provided

Comments and Discussions

 
GeneralMy version PinmemberPhilippe Lhoste10-Sep-01 2:05 
GeneralID_ vs IDC_ PinmemberDanG23-Aug-01 15:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 11 Aug 2001
Article Copyright 2001 by Roy Luo
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid