Results 1 to 3 of 3
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    obtain the name of the launching script (word 2000

    The embedded script (on my machine) launches Word and opens a document to perform a task.
    In this case, the attached document merely displays a MsgBox window.
    I'd like the document code to access the VBScript file and obtain data from that file,
    typically data lines following the command "objWord.Documents.Open".
    I can't find anything in the Document object or in the Parent object that indicates the source of the object,
    that is, how/from where it was launched.
    In my particular case I've been looking for anything that suggests "b:RunWordMacro.vbs".
    Can anyone offer a suggested path of research?

    <pre>Set objWord = CreateObject("Word.Application")
    objWord.Visible = True
    Set objDoc = objWord.Documents.Open("Boc1.doc")
    '{{}} Here is the first line of data.
    '{{}} Here is another line of data
    '{{}} Data lines are recognisable by my convention of wiggly-braces following a single quote</pre>

    Attached Files Attached Files

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: obtain the name of the launching script (word

    A script knows its own path (WScript.ScriptFullName), but that probably doesn't help you here unless you can "stash" it somewhere Word can find (environment variable? text file?) or can pass it to Word (e.g., as a command line parameter).

    The Windows API might reveal a parent-child relationship between the Windows Script Host and the relevant instance of Microsoft Word, and perhaps the properties of the parent might include the name of the script. Just a thought, as I haven't tried to figure that out and must rush off to lunch.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: obtain the name of the launching script (word

    > I haven't tried to figure that out and must rush off to lunch.
    Lunch is on me anywhere in Toronto, even the King Eddie!
    Thanks Jefferson:<pre>Set objWord = CreateObject("Word.Application")
    objWord.Visible = True
    Set objDoc = objWord.Documents.Open("Boc1.doc")
    Set objSelection = objWord.Selection
    objSelection.TypeText WScript.ScriptFullName
    </pre>

    If I get the name of the script into the document body, my VBA can pick it up from there and do the rest.
    Better yet: The user can save the document with the name of the calling script AND the resultant code.

    The document will be a template set up with a reference to an application template.
    The "data' in the VBScript is the text of a call to a function within that application template.
    Thus:<pre>Sub Test
    msgbox SequenceOfOperations(SourceTransferFiles:="True", _
    SourceLevels:="-1",SourceIncludeEmptyFolders:="True", _
    SourceAttributes8bits:="Null,Null,Null,Null,Null,N ull,Null,Null,", _
    ActionIdentifilerTags:="True",ActionDeleteSourceFi les:="True", _
    ActionSetAttributeBits:="Null,Null,Null,Null,Null, Null,Null,Null,", _
    SourceFolder:="D:Blotter20080619",TargetFolder:="B :",ActionLOBCode:="A03", _
    ActionActiveRetainDelete:="A",ActionOpenClosed:="O ",ActionOriginalCopy:="O")
    end sub</pre>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •