Results 1 to 12 of 12
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Germany, Germany
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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 <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

  2. #2
    3 Star Lounger
    Join Date
    May 2002
    Location
    Mpls, Minnesota, USA
    Posts
    271
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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
    Chuck Reimer
    I'm from the Government and I'm here to help...

  3. #3
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Germany, Germany
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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 <img src=/S/thinks.gif border=0 alt=thinks width=15 height=15>

  4. #4
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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).
    Legare Coleman

  5. #5
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Germany, Germany
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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

  6. #6
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

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

    I have never used a Class event in Excel, but what happens if you create a class module and insert code like...
    <pre>Public WithEvents appevent As Application

    Private Sub appevent_WorkbookOpen(ByVal Wb As Workbook)

    End Sub
    </pre>

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

    StuartR

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

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

    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.

  8. #8
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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.
    Legare Coleman

  9. #9
    2 Star Lounger
    Join Date
    Mar 2002
    Location
    Germany, Germany
    Posts
    169
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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 <img src=/S/compute.gif border=0 alt=compute width=40 height=20>

  10. #10
    Lounger
    Join Date
    Aug 2002
    Location
    Boise, Idaho, USA
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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.

  11. #11
    Lounger
    Join Date
    Aug 2002
    Location
    Boise, Idaho, USA
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    Hmmm <img src=/S/hmmn.gif border=0 alt=hmmn width=15 height=15>. 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.

  12. #12
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts

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

    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...
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

Posting Permissions

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