daniels012
Well-known Member
- Joined
- Jan 13, 2005
- Messages
- 5,219
Here is my code:
I check it and the file name is exactly the same.
Am I missing something? The code worked fine for a long time. It changed when I created a macro enabled file. COuld that be the issue?
Thank you,
Michael D
Code:
Sub Save_To_Client()
Dim strfilename As String, strPath As String, strPath2 As String, CurrPath As String, foldName As String, MyVal As String
Dim MyPath As String, MyPathExtended As String, strClientName As String, strPdfName As String, strName2Clients As String
Dim wsDest As Worksheet, strEstimateName As String, strPath3 As String, strPath4 As String, MyVal2 As String, strProp4Zestim As String
Dim WB1 As Workbook
Dim WB2 As Workbook
Dim fso, Estfile As String, sfol As String, dfol As String
Application.ScreenUpdating = False
Set WB1 = ActiveWorkbook
WB1.Save 'First thing, save my work
CurrPath = WB1.Path
strfilename = Range("S16").Value & ".xlsm" '//Company Name & PROP & Proposal#
strPdfName = Range("S16").Value & ".pdf" '//Company Name & PROP & Proposal#
strPath = "C:\Dropbox\Clients\"
strPath2 = "C:\Users\User\Google Drive\"
strPath3 = "C:\Dropbox\ZProp\"
strPath4 = "C:\Dropbox\ZEstim\"
foldName = Trim(Range("S15")) 'This is the folder name after the "Client name and city" folder
MyVal = Range("T10").Value 'First letter of the clients name for the alphabatized choice
MyVal2 = Range("S10").Value 'Range of alphabatized letters for Clients name
strClientName = Range("S17").Value 'Client name and City for the folder after the "letter"
strName2Clients = Range("U5").Value 'This is the name of the reverse file name
strProp4Zestim = Range("U16").Value 'This is the name to go to Zestimating
' On Error Resume Next
Set wsDest = WB1.Worksheets("EstimatingData") 'This brings up EstimatingData sheet
wsDest.Range("A1").Value = RipIllegals(wsDest.Range("A1")) 'Removes Ilegal Characters
wsDest.Range("N1").Value = RipIllegals(wsDest.Range("N1")) 'Removes Ilegal Characters
MyPath = strPath & MyVal & "\" & strClientName
'This is "Clients\" then "alpha letter\' then "Client name and city".
If Len(Dir(MyPath, vbDirectory)) = 0 Then
MkDir MyPath
End If
MyPathExtended = MyPath & "\" & foldName
'MyPath = "Clients\" then "alpha letter\' then "Client name and city" then the "last folder".
If Len(Dir(MyPathExtended, vbDirectory)) = 0 Then
MkDir MyPathExtended
End If
ActiveWorkbook.SaveAs strPath3 & MyVal2 & "\" & strfilename
' Copies to "ZProp"
' strPath3 = "C:\Dropbox\ZProp\" & MyVal12 is like A-E & strfilename = Range("S16").Value & ".xlsm"
Set WB2 = Workbooks.Open(Filename:=strPath2 & "Proposal for XL.xlsm")
' strPath2 = "C:\Users\User\Google Drive\" & Open "Proposal for XL"
If MsgBox("Is this a Residential Job?", vbQuestion + vbYesNo) = vbYes Then
Sheets(Array("FRONT", "Res. Back")).Select
Else
Sheets(Array("FRONT", "BACK")).Select
End If
' /////////////////////////////////////////////////////////////////////////
'This copies a PDF to Clients
Sheets("FRONT").Activate
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
MyPathExtended & "\" & strPdfName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:= _
False
'This copies a PDF to Clients
ActiveWorkbook.Sheets("FRONT").Select
' Estfile = Range("U17").Value
' change to match the file name ****Changed from U10 to U17 on 5-3-2011
' something like C:\Dropbox\Clients\EMORY UNIVERSITY HOSPITAL G251-256, 231-23 2.22.2016 11.27Prop18324.xlsm
sfol = strPath
' dropbox directory strPath = "C:\Dropbox\Clients\"
dfol = strPath4 & MyVal2 & "\"
' strPath4 = "C:\Dropbox\ZEstim\" & MyVal2 = Range("S10").Value //This is like A-E
Set fso = CreateObject("Scripting.FileSystemObject")
' If Not fso.FileExists(sfol & Estfile) Then (Changed next line on2.22.2016)
If Not fso.FileExists(Range("U18").Value) Then
' MsgBox sfol & Estfile & " does not exist!", vbExclamation, "Source File Missing"
MsgBox Range("U18").Value & " does not exist!", vbExclamation, "Source File Missing"
' ElseIf Not fso.FileExists(dfol & Estfile) Then (Changed next line on2.22.2016)
ElseIf Not fso.FileExists(Range("U19").Value) Then
' fso.MoveFile (sfol & Estfile), dfol (Changed next line on2.22.2016)
fso.MoveFile (Range("U18").Value), dfol
Else
MsgBox Range("U19").Value & " already exists!", vbExclamation, "Destination File Exists"
End If
Application.ActiveSheet.Range("Q1").Value = Range("x24").Value
Range("Q4:U4").Select
Selection.Copy
' ActiveWorkbook.Sheets("FRONT").Range("Q4:U4").Interior.ColorIndex = 6
MsgBox "Copy the highlighted red text (next to the proposal number) and paste it to the Sale Projections website"
On Error GoTo 0
ChDir CurrPath
Application.ScreenUpdating = True
WB1.Close
' MsgBox "Copy the red text (next to the proposal number) and paste it to the Sale Projections website"
End Sub
I check it and the file name is exactly the same.
Am I missing something? The code worked fine for a long time. It changed when I created a macro enabled file. COuld that be the issue?
Thank you,
Michael D