Hi guys,
I have the following excel code that saves my worksheet as a pdf file and now I am trying to find a way to modify the code so it saves the worksheet not as a pdf file but as another excel workbook and also if possible, could you please write a separate code to email the saved worksheet to other people?
- is it possible to add the feature to save the workbook manually so I can choose the location where I want to save the file?
- I believe the code for 'page setup' can be removed? since I want to save the entire worksheet as workbook?
Sub Save_Worksheet()
Dim ws As Worksheet
Dim v As Variant
v = Application.GetSaveAsFilename(Range("A1").Value, "PDF Files (*.pdf), *.pdf")
If VarType(v) <> vbString Then Exit Sub
If Dir(v) <> "" Then
If MsgBox("File already exits") = vbNo Then Exit Sub
End If
Set ws = Sheets("Sheet1")
With ws.PageSetup
.PrintArea = "$K$1:$AH$57"
.FitToPagesWide = 1
.FitToPagesTall = 1
.Zoom = False
.CenterHorizontally = True
.Orientation = xlPortrait
End With
With ws
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=v, Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, From:=1, To:=3, OpenAfterPublish:=True
End With
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Range("A1").Select
End Sub
I'd also like to use the range "A1" as a save as filename destination in the code.
Any help?
Much appreciated in advance.
Jin
Bookmarks