Open Files From Database

  • Hi all experts...


    I just want to ask about how to open file from the database which is in specific directory using VBA. The condition is when I write/search the directory name from the database and then click a button in excel worksheet, the VBA will open the chosen file.

  • Re: Open Files From Database


    After reading your post, I wasn't sure what you wanted. Are you simply trying to open a file on your network, or are you trying to query a database?


    If the former case is true, and it's a workbook, you need to use the workbook open command.

    Code
    Workbooks.Open Filename:= "C:\YourPath\YourFilename.xls"


    Or to open something else with Excel (in Excel) as text:

    Code
    Workbooks.OpenText Filename:= "C:\YourPath\YourFilename.txt"


    There are also other ways to open microsoft applications with VBA. If not a microsoft application, you can create a batch file and use VBA's shell command to execute it. Or, sometimes, creating a hyperlink and following it works too.


    If the latter case--that is, you're trying to query a database and retrieve information--your question might be better answered at the Excel SQL forum here.

  • Open File From Directory


    Hi all...


    Can anyone experts can provides me the code to open a file in a folder(lot number) from the directory(local disk C) using one command button and 2 textboxs?Below is the illustaration what i'm going to do..


    1. User enter directory and specify lot number(textbox). Then click Start button(command button).


    [Blocked Image: http://i110.photobucket.com/albums/n81/poex_xp/project2.jpg]


    In the lot number folder have the file which need to be open.


    2. After Start button is clicked the file is open.


    Please anyone help me. Thanks

  • Re: Open File From Directory


    Thanks...


    How about the command button and the textbox codes?
    The code that you gives me just to call the files or?I didn't understand..

  • Re: Open File From Directory


    Right-click in the Start button in the userform module, select View Code, and put the Workbook.Open statement in the Start button Click event.

    [SIZE=1]Entia non sunt multiplicanda sine necessitate.[/SIZE]

  • Re: Open File From Directory


    Oopsy, you're not using a userform, sorry.


    Were the text boxes and buttons created using the Forms toolbar or the Controls toolbar?

    [SIZE=1]Entia non sunt multiplicanda sine necessitate.[/SIZE]

  • Re: Open File From Directory


    ok thanks shg...i can open the file now..


    I have another problems to ask.


    By referring the new attached file, using same program(illustration above), I have to copy all the datas which have a value only (total=0 is ignored) in the Bin_Trip worksheet(highlight in image below), then all this data will be paste to other new workbook. All this job is done by clicking the start button. The new workbook with the pasted datas is the finish result.


    [Blocked Image: http://i110.photobucket.com/albums/n81/poex_xp/yields.jpg]

  • Re: Open File From Directory


    AFIQ, forum protocol is one question answered per thread, so that thread titles can be usefully searched by others. Please start a new thread.

    [SIZE=1]Entia non sunt multiplicanda sine necessitate.[/SIZE]

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!