RunApp with a reference to a non EXE command line argument

K

Kathy Webster

I have a macro in Access XP whose action is RunApp.
The Action Argument Command Line is:

wpwin12.exe /m-merge.wcm.

This opens WordPerfect and runs the WordPerfect macro "merge.wcm."
It works fine, but WordPerfect recommends I remove everything but
"merge.wcm" from the command line because of some other WP issues.
When I remove "wpwin12.exe /m-" from the command line, leaving only
"merge.wcm" in the command line action argument, Access doesn't understand
the command. I get an error:

Access can't invoke the application using the RunApp action.

Perhaps RunApp only works with exe's? If I type "merge.wcm" in the windows
Run line (start, run ) it executes fine, so it appears the problem is at the
MS Access level. How should I call this command line from Access?

TIA,
Kathy
 
D

Douglas J. Steele

Yes, RunApp only works with exes.

If you're using a macro, I don't think you have any choice other than using
the first syntax you mentions.

If you switch you using VBA, you might be able to get away with
Application.FollowHyperlink "merge.wcm"
 
K

Kathy Webster

Thank you. It seems to work... however... I get the MsgBox "Error" also.
In my macro, I put RunCode wpmacro(), and this
is what I put in the module called Module1:

Public Function wpmacro() As Boolean

On Local Error GoTo Err
Application.FollowHyperlink "L:\LP\merge.wcm"
Err:
MsgBox "Error"

End Function

You know me by now, my VB is less than sketchy, so I am useless at
troubleshooting. :-(
-kathy
 
K

Kathy Webster

p.s. I forgot to mention that after following your VBA suggestion, this
dialog box that pops up, too:

Dialog Box Title : Microsoft Office
Opening merge.wcm
Some files can contain viruses or otherwise be harmful to your computer
..
It is important to be certain that this file is from a trustworthy
source.
Would you like to open this file?

What should I do to have the computer trust this file?
-kathy
 
K

Kathy Webster

Thank you. I am still getting the error message box that I mentioned in the
other email. The macro executes as I want, but Access still gives an error:
In my macro, I put RunCode wpmacro(), and this
is what I put in the module called Module1:

Public Function wpmacro() As Boolean

On Local Error GoTo Err
Application.FollowHyperlink "L:\LP\merge.wcm"
Err:
MsgBox "Error"

End Function

Any thoughts?
-kathy
 
D

Douglas J. Steele

You're getting the error message because program flow is going to the
message box whether or not an error occurred.

Try:

Public Function wpmacro() As Boolean
On Local Error GoTo Err

Application.FollowHyperlink "L:\LP\merge.wcm"

Exit:
Exit Function

Err:
MsgBox "Error"
Resume Exit

End Function
 
K

Kathy Webster

Thanks. Along these lines, I have another piece of code for another task
that, when erroring, should show the error message and die, but it shows the
error and continues as if an error were not encountered. The reason is that
this code is step 2 of a 3 step macro. So step 3 of the macro is
continuing. How can I make the code die on error, instead of continuing
with step 3 of the macro?
Thanks!

Public Function CorLib() As Boolean

On Local Error GoTo LocalError

' I deleted code here that identifies variables Filename and
DestName
' so that you don't have to wade through it

FileCopy Filename, DestName

Exit Function

LocalError:
MsgBox "Form has been removed from the Library. Please try again
after you are returned to the Main Menu."
'This is where it needs to kill everything and stop the macro that is
running

End Function

=================
 
D

Douglas J. Steele

You're showing VBA code, but talking macros. Macros don't currently have
much available in the way of error checking (they will in Access 2007), so
VBA is really the way to go.

Why isn't all the code in a single VBA module, rather than split?
 
K

Kathy Webster

Because my knowledge of VBA code is so limited. The best I can do is
accomplish some parts of the task through a few lines of a macro, then stick
in RunCode amidst the lines of macro, then go back to macro. I understand
macro conditional statements and drop down choices very well, but not VBA.
I wish I had your skills, but I don't. :)

Is there a way to keep step 4 from happening if error is encountered in step
3? Step 3 code is what I pasted below in prior email.

Macro:
1. if this, do this
2. if that, do that
3. if this, RunCode
4. do this
 
D

Douglas J. Steele

To be honest, I never use macros because, as I said earlier, they don't have
much error handling ability.

I don't believe what you're trying to do is possible using a macro, but
perhaps one of the macro experts will jump in with a possibility.

The VBA you've shown is fairly straight-forward, though. If you wanted the
copy done and then the WordPerfect macro opened, you'd just put the commands
one after the other:

Public Function wpmacro() As Boolean
On Local Error GoTo Err

FileCopy Filename, DestName
Application.FollowHyperlink "L:\LP\merge.wcm"

Exit:
Exit Function

Err:
MsgBox "Error"
Resume Exit

End Function

Now, if the file copy failed, the FollowHyperlink statement will not be
executed, since the error handling would exit the function.
 

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