JRC,
I'm curious why you didn't try the little Python program I gave you?
Saving those few lines into a file as "convert.py" or something, editing
the input/output file names, and you'd be done in minutes. And you'd
have something which will allow the automatation (for future file
conversions) which you wanted. Just curious.
Python is provided in Mac OS X ... they this because it's useful for
many things, including exactly the sort of think you want to do.
--rms
www.rmschneider.com
JRCwrote:
When you paste from a browser, it converts "spaces" to non-breaking spaces.
That is correct for HTML, but it is fatal in the compiler, where a
non-breaking space is a literal character, not a "blank"
Instead, paste the code into TextEdit.
In TextEdit, use the menu to "Make plain text".
Then copy in TextEdit and paste THAT into the VBA Editor.
Then it will compile and run
Cheers
On 10/12/09 7:22 PM, in article
(e-mail address removed), "JRC"
HiJRC,
I already answered this some days ago - in the Excel context in
microsoft.public.mac.office.excel, but you've given no feedback
there to the solution I posted.
--
Cheers
macropod
[Microsoft MVP - Word]
messagecom
...
Dear all:
I am currently working on a rather large document that I need to
format a certain specific way. The document includes nearly 57,000
lines of plain text that need to be indented according to a simple
rule so that it can then be imported into an application as a tab-
delimited file. A member from another forum suggested this might be
more easily done with Word instead of Excel so I decided to post this
questions here.
My system is a Mac G5 running the latest version of Leopard (not Snow
Leopard) which is 10.5.8 and I have Microsoft Office 2004 installed
(haven't upgraded to 2008 and will probably wait until next version to
upgrade).
Below is an example of the type of file I now have:
Body Regions;A01
Abdomen;A01.047
Abdominal Cavity;A01.047.025
Peritoneum;A01.047.025.600
Douglas' Pouch;A01.047.025.600.225
Mesentery;A01.047.025.600.451
Mesocolon;A01.047.025.600.451.535
Omentum;A01.047.025.600.573
Peritoneal Cavity;A01.047.025.600.678
Peritoneal Stomata;A01.047.025.600.700
Retroperitoneal Space;A01.047.025.750
Abdominal Wall;A01.047.050
Groin;A01.047.365
Inguinal Canal;A01.047.412
Umbilicus;A01.047.849
Back;A01.176
Lumbosacral Region;A01.176.519
Sacrococcygeal Region;A01.176.780
Breast;A01.236
Mammary Glands, Human;A01.236.249
This is just a small portion of the file I am working with. This is a
"flat" text file but what I need is a "hierarchical" or "tree
structure" file where each of these lines is indented with a number of
"tab keystrokes" corresponding to its level as depicted by the
alphanumeric code following the term. Example:
Body Regions;A01
Abdomen;A01.047
Abdominal Cavity;A01.047.025
Peritoneum;A01.047.025.600
Douglas' Pouch;A01.047.025..600..225
Mesentery;A01.047.025.600.451
Mesocolon;A01.047..025..600.451.535
Omentum;A01.047.025.600.573
Peritoneal Cavity;A01..047.025.600.678
Peritoneal Stomata;A01.047..025..600.700
Retroperitoneal Space;A01.047.025.750
Abdominal Wall;A01.047.050
Groin;A01.047.365
Inguinal Canal;A01.047.412
Umbilicus;A01.047.849
Back;A01.176
Lumbosacral Region;A01.176.519
Sacrococcygeal Region;A01.176.780
Breast;A01.236
Mammary Glands, Human;A01.236.249
As you will notice each line has been indented using the tab key a
number of times corresponding to the size of the alphanumeric code.
Lines with an alphanumeric code containing only 3 characters stayon
the left most position (no tabs). Example:
Body Regions;A01
Lines with an alphanumeric code containing 7 characters (example:
A01.047) are indented with one single tab keystroke. Example:
Abdomen;A01.047
Lines with an alphanumeric code containing 11 characters (example:
A01.047.025) are indented with two tab keystrokes. Example:
Abdominal Cavity;A01.047.025
Lines with an alphanumeric code containing 15 characters (example:
A01.047.025.600) are indented with three tab keystrokes. Example:
Peritoneum;A01.047.025.600
And so on, and so forth.
Once this step is finished and the file has been edited from a flat
text to one with a hierarchical or tree structure using tab entries
(to derive a tab-delimited file) the second part of the project
involves the removal of certain characters and replacement with
others. Basically I need the format to go from the existing:
Abdominal Cavity;A01.047.025
Where the term is followed by a semicolon and alphanumeric code.
To the following:
Abdominal Cavity [A01.047.025]
Where a space is added after the term, the semicolon is removed and
brackets are placed at the beginning and end of the alphanumeric
code.
Considering the size of my document as I stated (little less than
57,000 entries) I would like to find a way to automate the process.
How can these two processes be accomplished with the use of a macro ?
I have never worked with macros before and any help would be extremely
valuable and appreciated. I have both Excel 04 and Word 04 as part of
the Office 2004 package in case the information is relevant. I amnot
sure which of the applications would be better suited for this task
but am open to your suggestions.
Also I would appreciate suggestions on textbooks that would coverVBA
for Excel and Word. I would like to find books that would cover
everything from A to Z but with an approach that makes it easyfor a
beginner to understand and work with VBA on Microsoft Office for the
Mac. Any recommendations will be appreciated.
Thank you in advance for your help.
JRC
Hi Macropod.
I am sorry as I thought I had posted a reply to your post on the Excel
forum.
As I mentioned on some of my posts in that forum I tried your
subroutine as well as a few others that were posted but kept (and
still keep) getting error messages as I try to run them.
After copying and pasting your subroutine (and the others as well) I
tried to run them and Excel gave me an error message. The first line
appears highlighted in yellow and an arrow appears to the left of that
first line.
Do you know why this might be happening ?
I tried looking at a VBA book at Barnes and Noble but couldn't find
one specific for the Mac. There are several for Windows but I am not
sure what version of VBA on Windows would be equivalent to the one I
am running on the Mac (Office Mac 2004). Which of the Windows versions
of Excel with VBA would be equivalent to Office Mac 2004: the 2003 or
2007 version ?
Thanks,
JRC
--