需在excel中添加一个键“打印并保存”,并编制宏代码。每次打印时按“打印并保存”键(不用菜单中的打印图标),会将指定 的内容保存到另一个工作表中。 必须要做一个代码才能实现,代码如下:Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim dtmSHRQ As Date
Dim myFolder As String
Dim curFolder As String
Dim curName As String
Dim strFullName As String
myFolder = "D:\"
dtmSHRQ = ActiveSheet.Range("H7").Value
curFolder = myFolder & Format$(dtmSHRQ, "YYYYMMDD")
If Len(Dir(curFolder, vbDirectory)) = 0 Then
MkDir curFolder
End If
curName = Me.Name
strFullName = curFolder & "\" & curName
If Len(Dir(strFullName, vbDirectory)) > 0 Then
If MsgBox("文件" & Chr$(34) & strFullName & Chr$(34) & "已经存在,是否替换?", vbQuestion + vbYesNo + vbDefaultButton2, "Rousoft Office") = vbYes Then
Application.DisplayAlerts = False
Me.SaveAs strFullName
Application.DisplayAlerts = True
End If
Else
Me.SaveAs strFullName
End If
End Sub这样定义后就会产生一个宏键(打印并保存),不过这需要一定的编程基础,
温馨提示:答案为网友推荐,仅供参考