Macros to replace Visual Studio Macro

hongning2009
hongning2009 used Ask the Experts™
on
newbie question,  Is there a freeware/shareware program that do Macros like Visual Studio.   Found out Visual Studio Express does not have macros.  Would be nice to know of a popular macros program.  Thanks
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Chris BottomleySoftware Quality Lead Engineer
Top Expert 2011

Commented:
What do you actually want to program macros to do ... al the MS office applications have an editor built in.

Chris

Author

Commented:
Well basically to just manipulate data in a text file.
Chris BottomleySoftware Quality Lead Engineer
Top Expert 2011

Commented:
If you are on windows then we can probably use vbscript, what do you want to do, (again standard software this time in windows)?

Chris
Become a CompTIA Certified Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Author

Commented:
Okay situation,  you have tons of XML or ScriptFiles, or Specially formatted files.  You need to change certain values.  Typically you search for the term and you do a replace.  However sometimes it involves search for the term move a few (fix) lines down and change a value.  This can be done manually takes a long time  and also can be done efficiently thru Visual Studio macros.   However my problem is that the environment that I am running do not have Visual Studio or MS Office.  Is there an alternative shareware/freeware program that can serve as a substitute.
Chris BottomleySoftware Quality Lead Engineer
Top Expert 2011

Commented:
If you can define how to isolate the text for change then we can make the edits easily ... the key is that the sequence to identify what changes and how needs to be clearly defined.

Depending on how you want it to work we can then create a VB Script that will cycle through all the files in a folder and make the relevant changes to each of them before saving.

Key is you defining how the files are selected and what the nature of the edits is.

Chris

Author

Commented:
Cool a simple sample and how you would write it in vbscript would help a lot in me understanding it.
Chris BottomleySoftware Quality Lead Engineer
Top Expert 2011

Commented:
Happy to create it but first off need some idea of the process i.e.

1. All files in a folder:

2. What or how much  is searched for and what is replaced

Chris

Author

Commented:
Sample the following codes repeat several time for various field in NAME=  This files has extension .fdg

One root directory common and several sub-directories with the file .fdg in them

[FIELD 6, FORM 3]
NAME=remit_amount
DISPLAY_NAME=Remit Amount
GROUP_NAME=
ZONE=1790,612,2328,660
CASCADE=False
FIELD_TYPE=OCR
ENABLE_RECOG=False
READ_ONLY=True
BATCH_BALANCING=False
PRESENTATION=None
CONFIDENCE=900
PRINT_TYPE=MACHINE
FONT=OMNI
DATA_TYPE=NUMERIC
ENABLE_DATATYPE_CHECK=True
TYPE_CASE=BOTH
SPECIAL_CHARS=,.-
SEGM_LINE=SINGLE_LINE
SEGM_ZONE=NONE
SEGM_COUNT=NONE
BLANK_SPACES=False
DOUBLE_KEY=False
BOOKMARK=False
MAX_REKEYS=0
REPEATABLE=False
MAX_CHARS=24
JUSTIFY=NONE
PADDING_CHAR=""
ENABLE_CHAREDIT=False
DATA_ENTRY_FIELD_TYPE=DATA_CAPTURE
FIELD_LEVEL=Internal
CHARS=0

A simple change is change the ENABLE_RECOG=False to ENABLE_RECOG = True

Thanks for the help
Chris BottomleySoftware Quality Lead Engineer
Top Expert 2011

Commented:
If these are xml files then we will need to keep them as so so can you provide the structure used?

APologies if it seems like all 'ask' but the data is needed to try and do the right job.

Chris

Author

Commented:
Its not XML its a flat file With the Above as the structure.  This repeats for each field.
Software Quality Lead Engineer
Top Expert 2011
Commented:
Apologies ... I thought I posted last night but to repeat ...

Try this saving it a any valid filename using a .vbs suffix, (for example paste into notepad)

Const ForReading = 1
Const ForWriting = 2

  	Set fso = CreateObject("Scripting.FileSystemObject")
	process fso, fso.getfolder("c:\deleteme\")

	sub process(fso, fldr)
		For each fil In fldr.files
			If lcase(fso.GetExtensionName(fil.name)) = "fdg" then
				Set oldFile = fso.OpenTextFile(fil.path, ForReading)
				strText = oldFile.ReadAll
				oldFile.Close
				strNewText = Replace(strText, "ENABLE_RECOG=False", "ENABLE_RECOG=True")

				Set newFile = fso.OpenTextFile(fil.path, ForWriting)
				newFile.WriteLine strNewText
				newFile.Close
			End if
		Next
		for each subfolder in fldr.subfolders
			process fso, subfolder
		next
	end sub

Open in new window


See the line:

      process fso, fso.getfolder("c:\deleteme\")

And edit this to reflect your starting folder.

Chris

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial