• File Management or How to use startup parameters (97/2000/XP)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » File Management or How to use startup parameters (97/2000/XP)

    Author
    Topic
    #374073

    Hello everybody!

    Today I’ve got an interesting question, and I’m not sure there is anybody who has a solution, but let’s see. In fact I doubt that it is possible to do this…
    I have programmed an application, which is able to manage projectfiles. These have their own extension (*.vzg) which is associated whith this Excel-Sheet. In this sheet I am able to save and open these files (which are acsii-based). To do this I’ve written some code and it works well.
    But here is the problem: If I double click one of these *.vzg-files in the explorer, I want my Excel-Sheet to start and open exactly this file (means open Excel and then start the open-file-macro). To do this I somehow have to be able to start this Excelfile whith a parameter or something so that my application gets to know that it has to open a specific *.vzg-file. Does anybody think this would be possible?
    Any help on this would be appreciated!

    Greetings, Porley confused

    Viewing 0 reply threads
    Author
    Replies
    • #603897

      You should be able to associate the extension .vzg with Excel. I created a sample file and right-clicked it -then selected Open With, scrolled down to Excel and clicked the box Always use.
      Now when you double click a file with that extension, it will start Excel and load the file you double-clicked.
      If you need the macros loaded at the same time, just put the macros in your Personal.xls file (it always opens when Excel does).
      If I understood your question, this should do it. I am using Excel 97 on an NT system.
      Good luck,
      Chuck

      • #603904

        Hello reimer!

        First of all: Thanks for your help. But I fear my problem isn’t that trivial. I’m sorry, I didn’t explain the problem properly. So I will try again. So I will start with the Excel-Workbook, which also could be seen as a programme (at least is has the functionality of a stand-alone application). This workbook does a lot of calculation which I need for some engineering stuff. On one sheet can be found some cells, which contain input data required for the calculation. These data can be saved as an *.vzg file (at least I decided to name them like this). The saving process works like this: the macro reads the values from the sheet and writes keywords and associated values to an ASCII-file (the mentioned *.vzg). Also I am able to (re)load this data from the file. I open the *.vzg file, search for the keywords and write the related value back into the worksheet. I do not want to open this file as an own workbook but to read the data and write them into my programmed Excel-Application. So if I double-click a *.vzg-file, I have to open the Excel-Application and then force this application to use my own macro for opening an *.vzg-file.
        As you can see, it’s not easy, and I’m not sure whether it is possible or not…
        So I’m really thankful for any offered help!

        Greetings, Porley thinks

        • #603994

          THIS THREAD may gety you started in the right direction. If this is similar to what you want to do we can help you customize it to your application. Your description does not give enough information to do it. If you can use this technique and need help modifying the code, please post samples of your workbook and the .vzg files (wiith dummy data if it is proprietary).

          • #604118

            Hello Legare Coleman!
            Thank you for your hint. This is perfectly what I already use for opening the.vzg file and it works very well. My problem is a little bit different, and I didn’t expect it being so difficult to explain. So I will try again. Every programme has its own extension (like .xls for Excel). If you double-click a file with this extension, the related programme starts and opens the double-clicked file. So this is very practicable behaviour and I want to use this for my own application. You may understand my Excel-application as an own programme – just like Excel itself). So if it really were a standalone application, I could link my extension .vzg to this programme, and everythink would work to my total satisfaction. But unfortunately my programme isn’t standalone but programmed in Excel. Now it is possible to relate my extension to the Excel-workbook. I’ve already tried, but what happens is that Excel and my sheet is openend (this is the first step!) and my .vzg-file isn’t read. What I want to do now is to force my application to open the double-clicked .vzg automatically. Therefor I have to let my application know that it was opened by double-clicking a .vzg-file. And this is my problem: is there any possibility to do this?
            I know, it’s a hard one, but maybe there is anybody out there who has a solution for this.
            Once again thanks to the people who already tried to help me.

            Many Greetings, Porley

            • #604148

              I have never used a Class event in Excel, but what happens if you create a class module and insert code like…

              Public WithEvents appevent As Application
                
              Private Sub appevent_WorkbookOpen(ByVal Wb As Workbook)
                
              End Sub
              

              Does this get called before the workbook actually gets opened? If so can you use it to do the processing you want?

              StuartR

            • #604150

              You might look into DDE. Excel uses this itself to open/print files from Windows Explorer.

              In Explorer, select Tools/Folder Options, File Types tab.
              In the list, select Microsoft Excel Worksheet, click Edit.
              In the list of actions, select Open, click Edit.

              You’ll see the macro commands Excel uses to open a file. (We’re talking oldfashioned Excel4 macros here, not VBA macros)

              I’m not an expert in this, so I don’t know how to do this. You’ll need to look up macro functions. Perhaps this link will help. Among other things, it contains a link to a download of the Excel macro help file.

            • #604269

              You could associate your .vzg file to Excel so that when it is double clicked Excel starts up and opens the .vzg file. Then in the Open event routine in the .vzg file you could have code to open the rest of the application files.

            • #604693

              Hello everybody!

              Thanks for your hints. I tried a lot during the weekend, but unfortunately nothing seems to work the way I need it. I tried to find some documentation for DDE, but everything I found told me I would need another application to exchange data with (I don’t have one, my application is only an Excel-sheet). I also tried out some stuff concerning the idea of defining a classmodule but didn’ succeed either. And also I’m not allowed to modify the *.vzg files. They are ASCII-files, which are also read by other programmes, and so it would lead to great confusion, if I changed them to Excel-files.
              But anyway, many thanks for the great ideas I found here. I’ve come to the conclusion that it doesn’t seem to be possible only with Excel. Now I will try another way. I will write a little VBScript, which creates a temporary file only containing the name and the path of the .vzg file. This will be stored in a temporary directory. If this file exists, Excel will read it and open the mentioned .vzg-file (this can be handled in an auto-open procedure). If it doesn’t exist, nothing will happen. I hope that it is possible to generate a Script which knows which file called it. At last I will associate the .vzg file with this script and hope it will work.
              So thanks for your assistance again!!

              Greetings, Porley compute

            • #612337

              Porley,

              If I understand you correctly, you want to open Excel and your program file (code.vzg) as well as a data file (data.vzg) when you double-click on the data file in Windows Explorer. If that’s the case, take advantage of the fact that Excel can open multiple files from the command line. For example, from the Run… menu:

              Excel code.vzg data.vzg

              Do be able to do this from Windows Explorer, you need to associate the.vzg file type with an action, as described earlier in the thread. From the Explorer menu, select View/Folder Options…/File type, etc. When you create the .vzg type, edit the Open action, and specify the Application used to perform action as something like this:

              “c:Program FilesMicrosoft OfficeOfficeEXCEL.EXE” “C:My Pathcode.vzg” “%1”

              This should open Excel, load the code file, then load the data file. I don’t think you will need to check the DDE box.

            • #612338

              Hmmm hmmn. Depending on how your program code works, you may want to load it after the data.vzg file, and modify your code to operate on the previously-opened .vzg workbook.

            • #612346

              You could make sure your application file is always loaded together with Excel. (put it in XLSTART or make an add-in out of it and install it)

              Then have it’s workbook_Open event procedure (the Thisworkbook module one) contain:

              Private Sub Workbook_Open()
              Application.OnTime Now + TimeValue(“00:00:01”), “CheckForVZG”
              End Sub

              And in a normal module:

              Option Explicit

              Dim sOpenedFile As String

              Sub CheckForVZG()
              Dim oWkbk As Workbook
              If Workbooks.Count = 0 Then Exit Sub
              For Each oWkbk In Workbooks
              If InStr(UCase(oWkbk.Name), “VZG”) Then
              sOpenedFile = oWkbk.FullName
              owkbk.close false
              Exit For
              End If
              Next
              MsgBox sOpenedFile
              End Sub

              Now you can use sOpenedFile to open the file the way you want.

              Of course this only works when Excel is not open yet…

    Viewing 0 reply threads
    Reply To: File Management or How to use startup parameters (97/2000/XP)

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

    Your information: