Save to pdf and excel

jerryg72

New Member
Joined
Dec 30, 2005
Messages
40
I have created a quotation format in excel and I have a macro in it which can save the invoice to a separate folder in.xlsx format. But is it possible for me to save the invoice to another folder in .pdf format? When the file get saved, it is saved as protected since the master file is protected. Is there any option to remove the protection on the new filed when it is saved ?


The macro that I used is:-

Sub PostToRegister()
Dim WS1 As Worksheet
Dim WS2 As Worksheet
Set WS1 = Worksheets("Quotation")
Set WS2 = Worksheets("Register")
'Figure out which Row is Next
NextRow = WS2.Cells(Rows.Count, 3).End(xlUp).Row + 1

'Write Important Values to Register
WS2.Cells(NextRow, 3).Resize(1, 6).Value = Array(WS1.Range("R11"), WS1.Range("Q11"), _
WS1.Range("K10"), WS1.Range("C11"), WS1.Range("C12"), WS1.Range("W36"))

End Sub
Sub NextInvoiceNumber()
Range("Q11").Value = Range("Q11").Value + 1
Range("K10:N10, B16:Y35, L37:T37, G38:T41, W11:AD11, O13:AD13").ClearContents
End Sub


Sub SaveInvoiceWithNewFileName()
Dim NewFN As Variant
PostToRegister
ActiveSheet.Copy
NewFN = "C:\Users\Jerry\Desktop\Invoice" & Range("Q11") & "_" & Format(Now(), "yyyy-mm-dd") & ".xlsx"
ActiveWorkbook.SaveAs NewFN, FileFormat:=xlOpenXMLWorkbook
ActiveWorkbook.Close
NextInvoiceNumber
End Sub

Please help. Thank you
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Have you tried:

Code:
ThisWorkbook.Unprotect

'your code here to save copy

ThisWorkbook.Protect
 
Upvote 0
Before and after you run your code... like:

Code:
Sub yourMacroName()

ThisWorkbook.Unprotect

'the rest of your subroutine/macro/code goes here

ThisWorkbook.Protect

End Sub
 
Upvote 0
Can I ask one more quick question please? Is there any way to deactivate/remove the formulas in the new file? Just the value is needed. Thanks again
 
Upvote 0
Use pastespecial

Range("A1:A10").Copy
Range("B1").PasteSpecial xlPasteValues

(for example) not sure exactly what your code is doing I'd have to look closer
 
Upvote 0

Forum statistics

Threads
1,214,866
Messages
6,121,996
Members
449,060
Latest member
mtsheetz

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