|
本帖最后由 crazynet 于 2021-1-5 14:37 编辑
求VBA 导出成PDF代码,带自定义重命名或者指定单元格为名称的功能,谢谢
找到一个,如何修改成指定工作表,而不是当前工作表?
- Sub PDFActiveSheet()
- Dim wsA As Worksheet
- Dim wbA As Workbook
- Dim strTime As String
- Dim strName As String
- Dim strPath As String
- Dim strFile As String
- Dim strPathFile As String
- Dim myFile As Variant
- On Error GoTo errHandler
- Set wbA = ActiveWorkbook
- Set wsA = ActiveSheet
- strTime = Format(Now(), "yyyymmdd\_hhmm")
- strPath = wbA.Path
- If strPath = "" Then
- strPath = Application.DefaultFilePath
- End If
- strPath = strPath & ""
- strName = Replace(wsA.Name, " ", "")
- strName = Replace(strName, ".", "_")
- strFile = strName & "_" & strTime & ".pdf"
- strPathFile = strPath & strFile
- myFile = Application.GetSaveAsFilename _
- (InitialFileName:=strPathFile, _
- FileFilter:="PDF Files (*.pdf), *.pdf", _
- Title:="Select Folder and FileName to save")
- If myFile <> "False" Then
- wsA.ExportAsFixedFormat _
- Type:=xlTypePDF, _
- Filename:=myFile, _
- Quality:=xlQualityStandard, _
- IncludeDocProperties:=True, _
- IgnorePrintAreas:=False, _
- OpenAfterPublish:=False
- MsgBox "Les QrCodes ont été exporter dans le fichier PDF" _
- & vbCrLf _
- & myFile
- End If
- exitHandler:
- Exit Sub
- errHandler:
- MsgBox "Erreur lors de l'exportation"
- Resume exitHandler
- End Sub
复制代码
|
|