Closed Thread
Results 1 to 3 of 3

code problems

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

    code problems

    This is what I tried and got a error at strFile = Dir$

    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

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: code problems

    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
    If posting code please use code tags, see here.

  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,944

    Re: code problems

    Welcome to the Forum, unfortunately:

    This is a duplicate post and as such does not comply with Rule 5 of our forum rules. This thread will now be closed, you may continue in your other thread.

    http://www.excelforum.com/excel-prog...ing-files.html

    Thread Closed.
    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

Closed 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