Code needs help saving file (Excel compatibility 97 2003)

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
I have the code below. It always saves to the desktop. And then I have to move it manually to the correct Dropbox Folder. Any Idea Why?
Is there something in the code that would not be working with older Excel files since I am using (Excel 97/2000) compatibility mode?

Thank You for any help!
Michael

Code:
Sub SaveToClientsOrDesktop()

     Dim DBPath As String, myFileName As String, DTAddress As String, ans As String, DBPathEstim As String
        myFileName = Worksheets("Estimating").Range("A10").Value & ".xls"
        DBPath = Left(Application.ThisWorkbook.Path, Len(Application.ThisWorkbook.Path) - 19) & "Clients\"
        DBPathEstim = Left(Application.ThisWorkbook.Path, Len(Application.ThisWorkbook.Path) - 19) & "SurfaceSystemsFIles\Estimating2010.xls"
        DTAddress = CreateObject("WScript.Shell").SpecialFolders("Desktop") & Application.PathSeparator
            If Dir(DBPath, vbDirectory) <> "" Then
                ActiveWorkbook.SaveAs DBPath & myFileName
            Else
                ActiveWorkbook.SaveAs DTAddress & myFileName
                MsgBox "Be sure to go to the desktop, move your saved file into to dropbox. "
            End If
        ans = MsgBox("Do you want to do another Estimating sheet FOR THIS SAME CLIENT?", vbQuestion + vbYesNo, "???")

            If ans = vbNo Then
                ActiveWorkbook.Close
            Else
                Workbooks.Open DBPathEstim
                Workbooks(myFileName).Worksheets("Worksheet").Range("B5:B18").Copy Destination:=Workbooks("Estimating2010.xls").Worksheets("Worksheet").Range("B5")
                Workbooks(myFileName).Close
                'EraseWorksheetLeaveAddress
            End If
End Sub
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Try removing the "\" after Clients from this line:

DBPath = Left(Application.ThisWorkbook.Path, Len(Application.ThisWorkbook.Path) - 19) & "Clients\"

Otherwise, it will never save to the correct folder.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,833
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top