1 Reply Latest reply on Dec 6, 2011 3:30 PM by Jbsherry

    ActiveX can't Identify document names when hosted

    Jbsherry

      Hi,

      I'm working on a project that requires activex with FMP 11 and FMS11. Mycode checks to see if a file is open, and executes a script if it is. The problem is it works only if the file is open locally, not from fms.

       

      FMApp = GetObject("", "FMPRO.Application")

      FMDocs = FMApp.Documents

      FMApp.Visible = True

      If (FMDocs Is Nothing Or FMDocs.Count = 0) Then

      MsgBox("The Filemaker Pro database must be opened first.")

      Else

       

       

      ' go find our target file

      For Each fmDoc In FMDocs

      If InStr(LCase(fmDoc.fullname), LCase("ExecuteScanScript.fp7")) > 0 Then

      ' this is our file, run the script

      fmDoc.dofmscript("Execute Scan Script")

      End If

      Next

       

       

      I'm testing for the existence of a document, and the test succeeds when the file is open locally, but fails when hosted. I've tried a few obvious variations, and tried to grok the list of open documents, so I could see what string to test for, but I'm very new to vb.net and failed at this last task.

       

      So, it works with a local file that runs the script in the hosted file, but I'd really rather access the hosted file directly if possible. Any suggestions would be appreciated.

       

      -jb

        • 1. Re: ActiveX can't Identify document names when hosted
          Jbsherry

          I'll answer my own question in case anyone is bumping their head on this. I added MsgBox(fmDoc.fullname) to the loop ( as below ) so I could see what names were being reported by vb. Local files included the file extension ".fp7" but hosted files did not. So I'm now able to execute a script in a hosted file.

          -jb

          ................

          For Each fmDoc In FMDocs

          MsgBox(fmDoc.fullname)

           

                          If InStr(LCase(fmDoc.fullname), LCase("ExecuteScanScript.fp7")) > 0 Then

                              ' this is our file, run the script

                              fmDoc.dofmscript("Execute Scan Script")