• getcommandlinea

    Author
    Topic
    #1767374

    I am using this (api?) in Excel 97 on Win 95 machine. It works great for retrieving parms. However, my VBA code bombs excel when I run this on Winy2k and Office Y2k. Anyone know if there is a work around? Anyone else retrieving parms in VBA code?

    Viewing 1 reply thread
    Author
    Replies
    • #1774658

      If I understand you correctly you want a kind of a command line to input values at runtime:

      In VBA you have 3 alternatives:

      Inputbox _Function_ where you input a string
      Inputbox _Method_ i.e. Application.Worksheetfunction.InputBox(…), where you can specify the type of input data.
      Msgbox Function which waits for the user to click a button and returns an integer of the clicked button.

    • #1774661

      The api for Win95 is 16 bit. The closest I can come in Win32 is this:

      Public Declare Function CommandLineToArgv Lib “shell32” Alias “CommandLineToArgvW” (ByVal lpCmdLine As String, pNumArgs As Integer) As Long

      However, VBA has a function called Command() that returns a variant containing the argument following the /cmd switch in a command line. Even though the help files says it isn’t available in Office applications, it works nicely in VBA code. I assume they mean it isn’t available from the UI. I can’t recall whether this was available in Office 97 or not, but it seems to me it was.

      • #1774688

        FYI, yes it’s available in 97.

        • #1774981

          What API is it in? It isn’t in the Windows32 API unless it’s so well hidden it doesn’t show up in the API viewer.

          • #1775074

            Charlotte,

            It’s built in to the UI.

            Try ?Command()

            in the Word 97 immediate window. Unless you started Word with something on the command line, you get a line feed.

            • #1775139

              OK, we just have a vocabulary problem. The IDE in Office isn’t considered part of the UI, probably because it’s where the developers play. In fact, I mentioned using the Command() function, which is VB/VBA by the way rather than Windows or Office UI. I assume its a wrapper for the Win32 API call GetCommandLine, although I accidentally pasted the wrong API call in my earlier post.

    Viewing 1 reply thread
    Reply To: getcommandlinea

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: