Start Winword problem...

J

Jeffery B Paarsa

Hello,

I have a template called "(MR)Patient Forms(Pkg).dot" which when I double
click on it, it runs the following Macro and it does the necessary tasks:
Sub AutoNew()
Application.Visible = False
Pforms.PVDate.Text = Date
Pforms.MultiPage1.Value = 0
Pforms.Show
End Sub

I want to do this via a start winword command. Here is what I execute at
the DOS prompt:
F:\MRMDinc>start winword /m:autonew /tf:\MrMDInc\"(MR)Patient Forms(Pkg).dot"
The above command opens a new Document1 doc from Template and also another
Word window opens with no document in it and goes away quickly... I do not
see the Pforms dialog as it is supposed to be executed and shown in autonew
macro as the last line Pforms.Show. First line of autonew macro also says
"Application.Visible = False" which is supposed to hide the newly opend
document from the Template!? This hidding also does not happen!

When I try to close the newly opend Document1 using the X box I am being
prompted a dialog box of : (" You cannot close Microsoft Office Word because
a dialog box is open. Click OK, switch to Word, and then close the dialog
box.") After clicking OK on this dialog box, I am being prompted by another
dialog box of: ("You have modified styles, building blocks (such as cover
pages or headers), or other content that is stored in "(MR)Patient
Forms(Pkg).dot". Do you want to save changes to "(MR)Patient
Forms(Pkg).dot"?") and this dialog box has 3 botton of Yes, No and Cancel...

What could be wrong that the behaviour of this template is totally different
when I double click on it than when I try to run it via Start Winword
command?
 
S

Steve Yandl

Jeff,

I don't have a great explanation for why your AutoNew() doesn't behave as
you expect but I can propose an alternate method that I've used. Consider
using a vbScript file as an intermediary and then from the command line you
would launch either Wscript.exe or Cscript.exe with the vbs file as an
argument rather than launch Winword.exe as you show. Instead of naming your
macro as AutoNew(), you would give it some other subscript name and the
Application.Visible line could go in the script rather than your sub.

For my test, I created the macro, "myMacroA()" and saved it in a template,
"C:\Test\myVBA.dot". The script is shown between the lines below:

'-----------------------------------------------

Set objWdApp = CreateObject("Word.Application")
objWdApp.Visible = False
objWdApp.Documents.Add("C:\Test\myVBA.dot")
objWdApp.Run "myMacroA"

'-----------------------------------------------

The script is just a text file created in notepad but given the extension
vbs instead of txt. I named it launchWinForm.vbs and then used the command
line
WScript.exe "C:\Scripts\launchWinForm.vbs"



Steve Yandl
 

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