ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
I have taken a code from a worksheet to also use on another worksheet but missing something as i see an error function not defined
The code in use is shown below.
This is what is supposed to happen.
The value in the active cell is deleted & this works fine.
The path to save the pdf file is C:\Users\Ian\Desktop\REMOTES ETC\DR\DR COPY INVOICES\" & Range("L4").Value & ".pdf
At this point i am on sheet DATABASE
The file that is to be saved is on sheet INVOICE & file name is taken from cell L4
I know its a simple issue but i just dont see it
The code in use is shown below.
This is what is supposed to happen.
The value in the active cell is deleted & this works fine.
The path to save the pdf file is C:\Users\Ian\Desktop\REMOTES ETC\DR\DR COPY INVOICES\" & Range("L4").Value & ".pdf
At this point i am on sheet DATABASE
The file that is to be saved is on sheet INVOICE & file name is taken from cell L4
I know its a simple issue but i just dont see it
Rich (BB code):
Private Sub CloseForm_Click()
Dim sPath As String, strFileName As String
ActiveCell = Null ' to clear the contents
strFileName = "C:\Users\Ian\Desktop\REMOTES ETC\DR\DR COPY INVOICES\" & Range("L4").Value & ".pdf"
If Dir(strFileName) <> vbNullString Then
MsgBox "INVOICE " & Range("L4").Value & " WAS NOT SAVED AS IT ALLREADY EXISTS" & vbNewLine & vbNewLine & "PLEASE CHECK FILE IN FOLDER THAT WILL NOW OPEN.", vbCritical + vbOKOnly, "INVOICE NOT SAVED MESSAGE"
VBA.Shell "explorer.exe /select, " & "" & strFileName & "", vbNormalFocus 'DUPLICATE INVOICE FOUND
Exit Sub
End If
strFileName = "C:\Users\Ian\Desktop\REMOTES ETC\DR\DR COPY INVOICES\" & Range("L4").Value & ".pdf"
With Worksheet("INV")
.ExportAsFixedFormat Type:=xlTypePDF, fileName:=strFileName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False
End With 'CURRENT INVOICE IS NOW SAVED
Unload RunTheCodeAgain
End Sub