Problem with Applescript - 1

T

teacherpoet

Version: 2008
Operating System: Mac OS X 10.4 (Tiger)
Processor: intel

Trying to get an Applescript I used in Mariner Write to work in Word '08 . . .

tell application "Microsoft Word"
if front document exists then
tell front document
copy LineIndex of selection to currentLine
copy (count of lines) to numLines
set dialogPrompt to "Go to Line (Range 1.." & (numLines as string) & ")"
display dialog dialogPrompt default answer currentLine buttons {"Cancel", "OK"} default button "OK"
if button returned of result is "OK" then
set currentLine to ((text returned of result) as integer)
if currentLine ≥ 1 and currentLine ≤ numLines then
--select character (offset of line currentLine)
--the first character of the line
--select line currentLine
--select the line
--select insertion point (offset of line currentLine)
--place the insertion point at the beginning
else
display dialog ¬
"Line index does not exist." buttons {"OK"} default button "OK" with icon note
end if
end if
end tell
else
display dialog ¬
"There is no active document." buttons {"OK"} default button "OK" with icon note
end if
end tell

What am I doing wrong?
 
D

Daiya Mitchell

Version: 2008
Operating System: Mac OS X 10.4 (Tiger)
Processor: intel

Trying to get an Applescript I used in Mariner Write to work in Word '08 . . .
I'm no Applescripter, but I suspect it would be easier for scripters to
help you if you said what the script was supposed to do. Also, is this
the exact same script you used in Mariner Write, or did you already
translate it for Word?
 
T

teacherpoet

My apologies . . . I should have indicated that the function of this script is to allow one to go to a designated line within a Word document. When it runs correctly, it opens a dialogue box with a field into which you enter the line to which you want to move, click a button, and you're there. Helps you move through a document faster than page up/page down or the scrollbar.

The only change I've made to the script is to replace Mariner write with Microsoft Word in initial tell command.
 
D

Daiya Mitchell

Okay. I had a feeling. Scripts will need to be re-written/translated for
Word, as a general principle--just subbing Word for MW is unlikely to
ever work, except maybe for something really simple like creating a new
document. But being a very novice scripter, I always think it's best to
work out how to do things manually first before trying to write code to
streamline it.

I guess you've turned on line numbering in Word, so that you can tell
which lines you want?

Check out the Edit | Go To dialog (cmd-G). Looks to me like it already
does exactly what you want your script to do. (Go To offers several
options, but I'm finding once I set it to Line, it stays that way, not
sure if it will persist after a re-launch--that might be something worth
scripting, if you have to keep constantly setting it to Line every time
you want to use it.)

Also, various navigating options are discussed at these links:
http://daiya.mvps.org/browseobject.htm
http://word.mvps.org/FAQs/Formatting/UsingOLView.htm
http://www.shaunakelly.com/word/documentmap/index.html
 
T

teacherpoet

Thanks. Edit>Go To (Command-G) does the trick, in fact. And I don't experience the persistence of Line that you describe; I can go from Line to Page and back again repeatedly, it clears itself each time.

Thanks too for the pointer on Browse Object. Very helpful.

I'll explore the Outline View option in time. The Document Map tutorial appears to address an earlier version of that function. In Word '08 the same icon takes you to Print Preview.

One question: You wrote, "I guess you've turned on line numbering in Word, so that you can tell which lines you want?" I don't see a way to turn on line numbering, and get nothing on this from the Help menu.
 
D

Daiya Mitchell

Thanks. Edit>Go To (Command-G) does the trick, in fact. And I don't experience the persistence of Line that you describe; I can go from Line to Page and back again repeatedly, it clears itself each time.

Huh, that's interesting. Mine comes up with my last choice still
selected. It's keyboard navigable, though--you can Shift-Tab, type L,
hit tab, enter number.
Thanks too for the pointer on Browse Object. Very helpful.

Obviously just a different implementation of the Go To dialog.
I'll explore the Outline View option in time. The Document Map tutorial appears to address an earlier version of that function.

That *is* a WinWord tutorial on the Doc Map, but the principles are all
the same. On the Mac, the Doc Map is View | Navigation Pane, and you can
choose between Thumbnails or the Document Map.
In Word '08 the same icon takes you to Print Preview.

Not sure what you mean, but you can put icons for either (or just about
anything, including GoTo) on your toolbar--brief tutorial here:
http://word.mvps.org/mac/customizeToolbars.html
One question: You wrote, "I guess you've turned on line numbering in Word, so that you can tell which lines you want?" I don't see a way to turn on line numbering, and get nothing on this from the Help menu.

Format | Document | Layout, click on Line Numbers, you can set it to
continuously number throughout.

Help is unfinished at present--make sure you are allowing online Help,
which will be added to over time.

I'm curious--what brings you to switch from Mariner Write to Word (or to
add Word), at this point?
 
D

Daiya Mitchell

Daiya said:
Format | Document | Layout, click on Line Numbers, you can set it to
continuously number throughout.

Help is unfinished at present--make sure you are allowing online Help,
which will be added to over time.

Actually, that *is* in Help, because I had to look it up. Look at the
bottom of the Help window to set online/offline Help.
 
T

teacherpoet

I had Online Help turned on, but got no relevant answer when I keyed in "line numbering." I do get the right answer when I switch to Offline Help. So I'll use that from now on. Thanks for the tip.

The Go To function seems to work on lines even if I have line numbering turned off, which is a relief; I don't want to look at those numbers all the time.

The only GoTo function that I can find to put on my toolbar would be Go To Next Page/Go To Previous Page. Neither are icons; they're the function names as just given. Too much toolbar real estate.

Thanks for pointing me toward the Navigation Pane -- very useful.

As for leaving Mariner Write . . . Basically, I'm migrating from AppleWorks, and tested Write for 18 months as an alternative. I took to it initially because its UI comes very close to the AW interface, so I felt at home. And I liked its stripped-down quality.

However, the latest iteration of Write, 3.7.2, has some serious weirdness, including a malfunctioning and bizarrely conceived endnote/footnote function. It doesn't open AppleWorks text files (which previous releases of Word for Mac will do). It doesn't give you an editable facing-pages view, which both AW and Word provide .. in short, it's missing some features I use regularly.

Beyond that, Mariner hasn't issued a new release since '05, has been promising one for at least a year, keeps issuing new apps and new releases of its other programs while making excuses for nothing new for Write. I'm not convinced that they have the commitment to this app that I want from developers.

Mariner currently has a chart up at its site comparing Write to Word (without specifying which releases are being compared). This implies that the comparison is between the latest release of Write and the latest release of Word. In fact, though they don't indicate this, it's between the latest release of Write and Word '04. In that chart, Write does better than Word on a number of features. But I've reviewed their claim against Word '08, and found that Word has come abreast of or even pulled ahead of Write in many of those features.

Presumably Mariner will release Write 4.0 sometime this year. Will it improve dramatically on the current iteration? Will it equal what Word '08 offers? I don't know. I just got tired of waiting. So I gave Word '08 a test drive. It does everything I need it to do, as did AppleWorks before that -- and I'm a full-time working freelance writer.

So I have left Mariner Write behind. Once I get all my text files out of various legacy formats and into Word rtf, I expect to use Word '08 exclusively as my word processor.

I'm writing an account of my migration AW 6-Word '08 for Mac Edition Radio. Look for it in about two weeks.
 
D

Daiya Mitchell

I had Online Help turned on, but got no relevant answer when I keyed in "line numbering." I do get the right answer when I switch to Offline Help. So I'll use that from now on. Thanks for the tip.

Huh. No, actually the problem is in the search--"Line numbers" gets the
right topic in Online Help. Nothing you can do about it--I'd use Online
Help and just experiment with terms, as Offline Help has far less
content than Online.
The only GoTo function that I can find to put on my toolbar would be Go To Next Page/Go To Previous Page. Neither are icons; they're the function names as just given. Too much toolbar real estate.
You can change them to use icons, it's described in the link I gave. But
no, things where you have to select an option from a dialog (like GoTo,
Languages, or Paste Special formats) are often not broken down as
individual built-in commands in Word--I just meant the basic equivalent
of cmd-G could be switched to a toolbar. You can probably script a "jump
ahead 30 lines" or "browse to next heading" if you really wanted to, but
scripts can only live in the script menu.
As for leaving Mariner Write . . . Basically, I'm migrating from AppleWorks, and tested Write for 18 months as an alternative. I took to it initially because its UI comes very close to the AW interface, so I felt at home. And I liked its stripped-down quality.

<snip>
Thanks, very interesting. I've not tried Mariner Write at all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top