Click here to Skip to main content
15,891,184 members
Articles / Programming Languages / VBScript

Reorder Resource ID Macro

Rate me:
Please Sign up or sign in to vote.
3.00/5 (2 votes)
10 Aug 2001CPOL 49.3K   8   2
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

VBScript
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)


Written By
Web Developer
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy version Pin
Philippe Lhoste10-Sep-01 2:05
Philippe Lhoste10-Sep-01 2:05 
GeneralID_ vs IDC_ Pin
.dan.g.23-Aug-01 15:35
professional.dan.g.23-Aug-01 15:35 
normally these have different ranges.

how is this handled?

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

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