+ Reply to Thread
Results 1 to 7 of 7

Code Problem, Need Advice on opening Files

  1. #1
    Registered User
    Join Date
    05-04-2013
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010
    Posts
    16

    Code Problem, Need Advice on opening Files

    how would I open all excel files in a folder that has something in the file name before
    PO-xxxx-xxxx-xxx

    so if it has FTL47934-PO-Tire Kingdom-1037-5-21-13 it will open the file but if it looks like this it leaves it alone PO-Tire Kingdom-1037-5-21-13

    the files are all located in a folder called poreqform
    Last edited by kmraz; 05-22-2013 at 07:45 AM. Reason: rule 1

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: open files

    Please Login or Register  to view this content.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: open files

    Your post does not comply with Rule 1 of our Forum RULES. Your post title should accurately and concisely describe your problem, not your anticipated solution.

    Use terms appropriate to a Google search. Poor thread titles, like Please Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will be addressed according to the OP's experience in the forum: If you have less than 10 posts, expect (and respond to) a request to change your thread title. If you have 10 or more posts, expect your post to be locked, so you can start a new thread with an appropriate title.

    To change a Title on your post, click EDIT then Go Advanced and change your title, if 2 days have passed ask a moderator to do it for you.
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    05-04-2013
    Location
    Florida, United States
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Code Problem, Need Advice on opening & saving Files

    This is what I tried and got a error at strFile = Dir$ (should this be moved to the end)?

    Sub savepotofolder()

    Dim strFile As String, strpath As String
    strpath = "D:\new sws folder\maintenance\poreq\"
    strFile = Dir$(strpath & "*PO*.xls*")
    Do While Len(strFile)
    If strFile Like "*?PO*" Then Workbooks.Open strpath & strFile
    strFile = Dir$

    ' saves poreqform with the file name taken from cell k69 in poreq folder
    Sheets("poreqform").Select
    Sheets("poreqform").Copy
    thisfile = Range("k69").Value
    strFolder$ = "D:\new sws folder\maintenance\poreq\" & Split(thisfile, "-")(3)
    If Len(Dir$(strFolder$, vbDirectory)) = 0 Then MkDir strFolder$
    ActiveWorkbook.SaveAs Filename:=strFolder$ & "\" & thisfile
    ActiveWorkbook.Close

    Loop





    End Sub

  5. #5
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Code Problem, Need Advice on opening Files

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 05-22-2013 at 11:54 AM.

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Code Problem, Need Advice on opening Files

    Hi, kmraz,

    you post does not follow the forum rules: no code tags, posted as http://www.excelforum.com/excel-prog...-problems.html as a new thread.

    CIao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Code Problem, Need Advice on opening Files

    kmraz, I strongly advise you to take a few moments and read the forum rules, it will make it much easier for all of us.

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code in [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    Edit: and please do not post duplicate threads. I have closed the other 1, you can continue here

+ 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