Results 1 to 2 of 2

Workbook.Open Problem ReDuex

Threaded View

  1. #1
    Registered User
    Join Date
    03-13-2008
    Posts
    2

    Workbook.Open Problem ReDuex

    The object of the macro is to open workbooks in one folder, "save as" into a new folder, apply the data values to a scorecard workbook and then delete the original workbook in the first folder. If I run the macro in the VBA Edit window, all goes well and the second folder contains all the workbook from the first folder and all the data is updated on the scorecard workbook. If I execute the macro from a shortcut key module the code "Stalls " on the first Workbooks.Open statement. The workbook opens and then no code is executed.
    Private Sub TestPaste()
    
    MyPath1 = "C:\Documents and Settings\browns\Desktop\Scratch1\"
    MyPath2 = "C:\Documents and Settings\browns\Desktop\Scratch2\"
    ScorecardName = "PasteTest Scorecard.xls"
    
    Myname = Dir(MyPath1 + "*.xls")     ' Retrieve the first entry.
    
    Do While Myname <> ""    ' Start the loop.
    
        ' Ignore the current directory and the encompassing directory.
        If Myname <> "." And Myname <> ".." Then
            
            strVar = MyPath1 + Myname
            Workbooks.Open Filename:=strVar
    
            strVar = MyPath2 + Myname
               
            Workbooks(Myname).Activate
            
            ChDir MyPath2
            ActiveWorkbook.SaveAs _
                Filename:=strVar, _
                FileFormat:= _
                xlNormal, Password:="", _
                WriteResPassword:="", _
                ReadOnlyRecommended:=False, _
                CreateBackup:=False
                
            Workbooks(ScorecardName).Activate
            strAns = Update_Paste_Values()
        
            strVar = MyPath1 + Myname
            Kill strVar
                   
        End If
        Myname = Dir    ' Get next entry.
    Loop
    End Sub
    Last edited by Leith Ross; 03-13-2008 at 02:42 PM. Reason: Added Code tags

Thread Information

Users Browsing this Thread

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

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