Topic
4 replies Latest Post - ‏2013-03-23T11:53:42Z by SystemAdmin
SystemAdmin
SystemAdmin
3180 Posts
ACCEPTED ANSWER

Pinned topic OLE ShowSave method of CommonDialog not working

‏2013-03-20T10:15:17Z |

Hi all,
I am trying to use the ShowSave method of an OLE CommonDialog in a DXL script, but I get the following error:
 

Problem with OLE Argument names

 


Everything works correctly with the similar ShowOpen method.
This is my code:

 

 

 

string selectFile(bool saveFile)
  {
  string dbMethod;
  string initDir = "C:/";
  int flags;
  int intAns;
  string retV;
 
  if (saveFile)
    {
    dbMethod = "ShowSave";
    flags = 0x80000 | 0x00002;
    }
  else
    {
    dbMethod = "ShowOpen";
    flags = 0x80000 | 0x01000 | 0x00800;
    }
  
  OleAutoObj objCD = oleCreateAutoObject("userAccounts.CommonDialog");
  retV = olePut(objCD, "filter", "Session files|*.*");
  if (retV != "") { infoBox("Set filter failed"); return (""); }
  retV = olePut(objCD, "InitialDir", initDir);
  if (retV != "") { infoBox("Set Init dir failed"); return (""); }
  retV = olePut(objCD, "Flags", flags);
  if (retV != "") { infoBox("Set flags failed"); return (""); }
 
  // Here comes the problem...
  retV = oleMethod (objCD, dbMethod, null, intAns);
  if (retV != "") { infoBox(dbMethod " failed: " retV); return (""); }
  if (intAns == 1)
    {
    retV = oleGet(objCD, "Filename", retV);
    if (retV != "") { infoBox("oleGet failed"); return (""); }
    return (retV);
    }
  return ("");
  }


Does anyone have any idea?
Is it possible that this method is not available on my machine? How can I find it?
I am using DOORS 8.3.0.1.

N.

 

 

Updated on 2014-01-06T10:26:31Z at 2014-01-06T10:26:31Z by iron-man
  • SystemAdmin
    SystemAdmin
    3180 Posts
    ACCEPTED ANSWER

    Re: OLE ShowSave method of CommonDialog not working

    ‏2013-03-20T10:43:02Z  in response to SystemAdmin

    Update: the code

    retV = oleGet(objCD, "Filename", retV);
    if (retV != "") { infoBox("oleGet failed"); return (""); }
    return (retV);
    


    was wrong and should be obviously replaced by something like this...

     

    string fName;
    retV = oleGet(objCD, "Filename", fName);
    if (retV != "") { infoBox("oleGet failed"); return (""); }
    return (fName);
    


    But this does not solve my initial problem.

     

    Updated on 2014-01-06T10:27:00Z at 2014-01-06T10:27:00Z by iron-man
  • SystemAdmin
    SystemAdmin
    3180 Posts
    ACCEPTED ANSWER

    Re: OLE ShowSave method of CommonDialog not working

    ‏2013-03-20T18:36:37Z  in response to SystemAdmin

    Hi

    First point is: You must not use null, if you have no parameters.

    ->
    replace
     

    retV = oleMethod (objCD, dbMethod, null, intAns);
    

     


    by

     

     

    retV = oleMethod (objCD, dbMethod, intAns);
    



    The next point: It may be possible that oleMethod is wrong and oleGet is correct.



     

    Updated on 2014-01-06T10:27:29Z at 2014-01-06T10:27:29Z by iron-man
    • SystemAdmin
      SystemAdmin
      3180 Posts
      ACCEPTED ANSWER

      Re: OLE ShowSave method of CommonDialog not working

      ‏2013-03-21T17:08:33Z  in response to SystemAdmin
      Hi Wolfgang,
      Thanks for the answer.
      I tried your suggestion, but I get the error

      -E- DXL: <addins/MyDOORS/Myfunc.dxl:62> incorrect arguments for function (oleMethod)

      It seems that the oleMethod needs exactly 4 arguments...

      Also, the same function runs correctly when the method name is "ShowOpen", even if the 3rd argument is null...

      N.
      • SystemAdmin
        SystemAdmin
        3180 Posts
        ACCEPTED ANSWER

        Re: OLE ShowSave method of CommonDialog not working

        ‏2013-03-23T11:53:42Z  in response to SystemAdmin

        Hello
         

        OleAutoObj objCD = oleCreateAutoObject("userAccounts.CommonDialog");
        

         


        The problem is: This dialog cannot be activiated by using an object delivered by microsoft. "userAccounts.CommonDialog" is the name of an own implementation, isn't it?

        If you use the dialog in VBA-Excel for example you have to call the "GetOpenFilename"-Method of an Excel.Application object. So I think you have problems to understand your own userAccounts-obejct?

        Best regards
        Wolfgang

         

        Updated on 2014-01-06T10:27:44Z at 2014-01-06T10:27:44Z by iron-man