+ Reply to Thread
Results 1 to 5 of 5

use text from textbox to indicate folder or worksheet name

  1. #1
    Registered User
    Join Date
    05-07-2010
    Location
    Home
    MS-Off Ver
    Excel 2007
    Posts
    2

    Exclamation use text from textbox to indicate folder or worksheet name

    All,

    I'm struggling with the following: I want to copy data from one workbook to another. Instead of programming the folder and workbook name as public constant in VB, I would like have textboxes in Excel where these folder and workbook names can be given. How do I do this?

    This is how I programmed it now in a module, followed by some public subs to open the source workbook, copy the data etc. called by a commandbutton:

    Public Const source_dir = "D:\My Documents\03 Klanten\Eurovet\data premix\"
    Public Const source_file = "OEEpremixweek 2010.14.xls"
    Public Const source_tab1 = "Week"
    Public Const target_dir = "D:\My Documents\03 Klanten\Eurovet"
    Public Const target_file = "Trends OEE Premix v04.xls"
    Public Const target_tab1 = "historie"

    In other words: in a sheet in Excel the user should be able to indicate in 4 textboxes what is going to be the source_dir, source_file, target_dir and target_file.

  2. #2
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: use text from textbox to indicate folder or worksheet name

    Hi

    Do you want the user to have four places to place the information or do you want them to browse and click on the one file they want?

    In the former case, I think there are at least two options:

    1. Use mulitple input boxes (Application.InputBox) sequentally placed to get all the information you need.
    2. Use a userform with four text boxes

    For the latter case, I think you can use the Application.GetOpenFilename to get the file name for the original file and destination file.

    Having said that, I am sure more experienced users can guide you better than me, but that's the way I would approach this situation.

    Good luck,

    abousetta

  3. #3
    Registered User
    Join Date
    05-07-2010
    Location
    Home
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: use text from textbox to indicate folder or worksheet name

    Quote Originally Posted by abousetta View Post
    Hi

    Do you want the user to have four places to place the information or do you want them to browse and click on the one file they want?

    In the former case, I think there are at least two options:

    1. Use mulitple input boxes (Application.InputBox) sequentally placed to get all the information you need.
    2. Use a userform with four text boxes

    For the latter case, I think you can use the Application.GetOpenFilename to get the file name for the original file and destination file.

    Having said that, I am sure more experienced users can guide you better than me, but that's the way I would approach this situation.

    Good luck,

    abousetta
    I will use four Textboxes, in which the folder and files names will be entered. The question is how to use this info in VBA;

    Public Const source_dir = TextBox1.Text does not work.

    What to do?

  4. #4
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: use text from textbox to indicate folder or worksheet name

    Try this and see if it does what you need.

    Good luck.

    abousetta
    Attached Files Attached Files

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: use text from textbox to indicate folder or worksheet name

    In textbox1.Text: "D:\My Documents\03 Klanten\Eurovet\data premix\"
    In textbox2.Text: "OEEpremixweek 2010.14.xls"
    In textbox3.Text: "Week"
    In textbox4.Text: "D:\My Documents\03 Klanten\Eurovet"
    In textbox5.Text: "Trends OEE Premix v04.xls"
    In textbox6.Text: "historie"

    Please Login or Register  to view this content.
    PS. I would prefer comboboxes. Sukses.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1