Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening Word document with parameters

Status
Not open for further replies.

vjee

Programmer
Jan 16, 2002
23
BE
Hi,

does anybody know if it's possible to open a word template using VB and pass parameters to this template and use them in a VBA-macro without passing them directly to the macro?

So, it's like opening the template with commandline parameters from the "Run" prompt, for example:

Winword d:\test.dot <param1>, <param2>,...

I can't find anything on this subject.

I do know how to pass parameters to a macro thru automation but this is not what I'm looking for.

Any help is appreciated.

Thanks,
Bart
 
If you can use an absolute path to tyour Winword.exe, you could do something like this:
Call Shell(&quot;C:\Program Files\MSOffice2k\Office\WINWORD.EXE&quot; & &quot; d:\test.dot <param1>, <param2>,...&quot;)

Cheers,
makeItSo

Andreas Galambos
EDP / Technical Support Specialist
Bowne Global Solutions Wuppertal, Germany
(andreas.galambos@bowneglobal.de)
HP:
 
uhmmm...
I think I explained it a little bit wrong. :)

At this moment, I call the macro through automation and pass the parameters directly to the macro :

Private Sub Command1_Click()
Dim wrdApp As Object
Dim wrdDoc As Object
Dim strFileName As String
Set wrdApp = CreateObject(&quot;Word.Application&quot;)

strFileName = &quot;d:\test.dot&quot;
Set wrdDoc = wrdApp.Documents.Add(strFileName)
'Call macro in template
wrdDoc.GetData &quot;This is a test.&quot;, &quot;d:\document.doc&quot;

Set wrdDoc = Nothing
Set wrdApp = Nothing
End Sub

This works, but this way, you call the macro within the word-template and pass the values directly to it.

I'm looking for a way to pass those values like a kind of commandline parameters so the values are passed to the word-document when opening it, not after it has already been opened. I don't know if this is possible?


Bart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top