+ Reply to Thread
Results 1 to 30 of 30

Textbox contents as folder/filepath

  1. #1
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Exclamation Textbox contents as folder/filepath

    Hi Guys,

    I need a little help with the below code
    The current code adds the contents of a textbox to the folderpath and pulls the file, But now i need the query to be in three parts:

    1). A two part folder path consisting of:

    a. (1st half ) "C:\Documents and Settings\carl.walker\My Documents\Reports\"
    b. (2nd half) "Contents from textbox1"

    2). The file name to pull from "textbox2"



    Any help with this would be great.
    Thanks in advance

    Carl

    Please Login or Register  to view this content.

  2. #2
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Textbox contents as folder/filepath

    Difficult to test with no sample workbook, but perhaps the below (or something like it) would do the trick:

    Please Login or Register  to view this content.
    BSB

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Textbox contents as folder/filepath

    Do you need to loop ?
    Please Login or Register  to view this content.
    BTW, variable declared as Const MUST be constant.

  4. #4
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Textbox contents as folder/filepath

    Hi Guys,

    Thanks for your replies,

    Hi Jindon,

    Your code looks as if it should work but when i run it, it displays the MsgBox "No Serial number available", as if its not seeing textbox " TBM1Serial"?
    Am I doing something wrong


    Thanks
    Carl


    Please Login or Register  to view this content.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Textbox contents as folder/filepath

    I though "FileName" would be a global variable, since you haven't assign within procedure.

    If not, you need to add one line
    Please Login or Register  to view this content.
    But, yes, you still need to loop, because the user would enter just "g" or something...

  6. #6
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Textbox contents as folder/filepath

    Hi Jindon,

    I done as you suggested but the msg box that appears, looks like its not adding the folder path from value "cmbDERS" to the string in order to find the file in that folder? also did i mention that the file is pdf?

    Please Login or Register  to view this content.
    regards
    carl

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Textbox contents as folder/filepath

    Try change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    And see how it goes...

  8. #8
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Textbox contents as folder/filepath

    Hi Jindon,

    I'm away from home so will test it out on Friday when I get back.

    Thanks again
    Carl

  9. #9
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Textbox contents as folder/filepath

    Hi Jindon,

    I tried with the altered line but still no joy unfortunately.....any ideas?

    Please Login or Register  to view this content.

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Textbox contents as folder/filepath

    I need to see the real value of
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Textbox contents as folder/filepath

    Hi Jindon,

    Value of cmbDERS is "a" which is the folder name

    Value of FileName is "a123" which is the file name

    I have attached a screen shot of the MsgBox that runs.

    Thanks
    Carl

    Screen grab.jpg

  12. #12
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Textbox contents as folder/filepath

    And with file
    Attached Images Attached Images

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Textbox contents as folder/filepath

    I can not see your picture... something is wrong I guess.

  14. #14
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Textbox contents as folder/filepath

    Hope this works!
    Attached Images Attached Images

  15. #15
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Textbox contents as folder/filepath

    It is OK this time..

    Can you also show me the mgsbox?
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Textbox contents as folder/filepath

    Hi,

    I only get that one msgbox shown above, even if i remove folder "a" from the "reports" folder?

    Carl

  17. #17
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Textbox contents as folder/filepath

    I mean
    Please Login or Register  to view this content.

  18. #18
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Textbox contents as folder/filepath

    Hi,

    I only get that one msgbox shown, even if i remove folder "a" from the "reports" folder?

    Carl

  19. #19
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Textbox contents as folder/filepath

    ignore last message

  20. #20
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Textbox contents as folder/filepath

    Second screen grab
    Attached Images Attached Images

  21. #21
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Textbox contents as folder/filepath

    Can you just try this?
    Please Login or Register  to view this content.

  22. #22
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Textbox contents as folder/filepath

    Nearly there now

    I get the msgbox shown and if i click ok if retrieves the correct file, but if i delete folder "a" i just get a blank msgbox?
    Attached Images Attached Images

  23. #23
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Textbox contents as folder/filepath

    What do you mean by "delete folder "a"" ?

  24. #24
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Textbox contents as folder/filepath

    I was doing some error checking to see what would happen if folder "a" didn't exist and to see if msg "no such file" ran.

  25. #25
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Textbox contents as folder/filepath

    Try change
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.

  26. #26
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Textbox contents as folder/filepath

    Hi Jindon,

    I tried the following but it does the same thing?

    Please Login or Register  to view this content.

  27. #27
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Textbox contents as folder/filepath

    What is "same thing"?

  28. #28
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Textbox contents as folder/filepath

    Sorry Jindon, I'm not explaining myself properly as usual

    When the code runs, msgbox "." appears, and only when i click "ok" it retrieves the file.
    What i need, is for it to retrieve the file without the msgbox appearing and need the msgbox to appear only if the folderpath does not exist.

    We're pretty much there now, thanks for your help so far

    Regards
    Carl

  29. #29
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,524

    Re: Textbox contents as folder/filepath

    You can delete unwanted msgbox, that was a msg for me to check....

  30. #30
    Registered User
    Join Date
    02-14-2012
    Location
    Newcastle, England
    MS-Off Ver
    Excel 2010
    Posts
    97

    Re: Textbox contents as folder/filepath

    Hi Jindon,

    Yes of course, what am I thinking

    Thanks for all your efforts with this, you've really helped me out

    Regards
    Carl

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Change filepath in macro based on textbox in form input
    By Jenkins27 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-27-2015, 09:21 PM
  2. Change filepath in macro based on textbox in form input
    By Jenkins27 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-27-2015, 09:12 PM
  3. [SOLVED] Open folder from a filepath in cell A1
    By singerbatfink in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-02-2015, 03:08 PM
  4. [SOLVED] Copy files from one folder to another folder (path in textbox)
    By yoko21 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-24-2014, 02:45 AM
  5. [SOLVED] Copying files from a selected filepath to a filepath mentioned in a worksheet's cell
    By subbby in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-10-2012, 03:59 PM
  6. Transfering Userform textbox filepath to worksheet as a hyperlink.
    By SJJ in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-29-2012, 05:17 PM
  7. Selecting a filepath based on cell contents
    By ceemo in forum Excel General
    Replies: 1
    Last Post: 06-25-2005, 09:05 AM

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