excel 打开后自动打印

来源:互联网 发布:石器时代野生宠物数据 编辑:程序博客网 时间:2024/04/30 03:02

 

打开一个命名为auto_open的宏

auto_open  写在模块1里

宏的内容如下:

 

Sub auto_open()   '设置一个自动运行的宏——auto_open

    Application.OnTime TimeValue("08:30:00"), "tx"   '设置提醒时间——08:30:00(可以根据需要修改),设置调用提醒宏——tx。

    Application.OnTime TimeValue("08:52:00"), "tx"   '再设置提醒一次。

End Sub

Sub tx()   '设置一个显示提醒消息的宏(名称要与上述自动运行宏中调用的名称一致)。

    Dim prtfileName As String
    prtfileName = "e:\\abc.xps"
 
    Sheets("Sheet1").Select
    ActiveSheet.PrintOut From:=1, To:=1, PrintToFile:=True, Copies:=1, PrToFileName:=prtfileName
    
 End Sub

 

PrintToFile:=True,PrToFileName:=prtfileName:写上这两参数,就会自动保存自动打印,不然会弹出对话框叫你保存,还是需要人工干预

 

 

原创粉丝点击