vb做的懒人值班表

因为每次都得填重复的 弄了个这个 不过下次改进下 弄开机自启

在这里插入图片描述

Option Explicit
Dim wapp As New Word.Application
Dim wapp1 As New Word.Application
Dim wapp2 As New Word.Application

Dim i As Integer
Dim wdoc As Word.Document
Dim wdoc2 As Word.Document
Dim zhoumo As Integer
Dim zhoumo1 As Integer
Dim zhoumo2 As Integer
Dim friday As Integer
Dim friday1 As Integer
Dim friday2 As Integer











Private Sub Command1_Click()

'Dim wdoc As Word.Document
Dim tablew As Word.table

Dim c As String
Static v As Long
Dim w As String
Dim q As String
Dim time As String
Dim ii As Integer
Dim iii As Integer
Dim day1 As Integer


'i = i + 1

ii = i - 4
iii = ii - i

'c = Year(Now) & "." & Month(Now)
c = Format(Now, "yyyy.mm.dd")



v = Weekday(Date)
If v = 1 Then
 w = "8:00"
q = "周末"
time = "12小时"

ElseIf v = 2 Then
 w = "17:00"
q = "延值"
time = "3小时"

ElseIf v = 3 Then
 w = "17:00"
q = "延值"
time = "3小时"

ElseIf v = 4 Then
 w = "17:00"
q = "延值"
time = "3小时"

ElseIf v = 5 Then
w = "17:00"
q = "延值"
time = "3小时"

ElseIf v = 6 Then
w = "17:00"
q = "延值"
time = "3小时"


If FileLen(App.Path & "\1234.txt") = 0 Then
Open "1234.txt" For Output As #1
friday2 = friday2 + 1
Print #1, friday2,
Close #1
Else
Open "1234.txt" For Input As #1
Input #1, friday1
End If
Close #1


'friday2 = friday2 + 1

'Open "1234.txt" For Output As #1
' print 语句后面加上逗号,
' 输出后不换行、输出项目后面自动加空格补齐到“制表定位”处
'Print #1, friday2,
'Print #1, "20150112103831",
'Print #1, "6.62",
'Print #1, "6.62",
'Print #1, "0.00",
'Print #1, "0.00",
'Print #1, "6.62",
'Close
'Open "1234.txt" For Input As #1
'Input #1, friday1 '读取文件中的一个数据,存放到变量a中
'Close


friday = friday1 + 1

Open "1234.txt" For Output As #1
' print 语句后面加上逗号,
' 输出后不换行、输出项目后面自动加空格补齐到“制表定位”处
Print #1, friday,
'Print #1, "20150112103831",
'Print #1, "6.62",
'Print #1, "6.62",
'Print #1, "0.00",
'Print #1, "0.00",
'Print #1, "6.62",
Close










ElseIf v = 7 Then
w = "8:00"
q = "周末"
time = "12小时"
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~存周六的次数
'zhoumo2 = 1
zhoumo2 = zhoumo2 + 1

Open "123.txt" For Output As #1
' print 语句后面加上逗号,
' 输出后不换行、输出项目后面自动加空格补齐到“制表定位”处
Print #1, zhoumo2,
'Print #1, "20150112103831",
'Print #1, "6.62",
'Print #1, "6.62",
'Print #1, "0.00",
'Print #1, "0.00",
'Print #1, "6.62",
Close
Open "123.txt" For Input As #1
Input #1, zhoumo1 '读取文件中的一个数据,存放到变量a中
Close


zhoumo = zhoumo1 - 1

Open "123.txt" For Output As #1
' print 语句后面加上逗号,
' 输出后不换行、输出项目后面自动加空格补齐到“制表定位”处
Print #1, zhoumo,
'Print #1, "20150112103831",
'Print #1, "6.62",
'Print #1, "6.62",
'Print #1, "0.00",
'Print #1, "0.00",
'Print #1, "6.62",
Close
End If






Set wdoc = wapp.Documents.Open("C:\Users\Administrator\Desktop\新建 Microsoft Word 文档 (4).docx")
'wapp.Visible = True
wapp.Selection.EndKey unit:=wdStory
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Dim table
'Set table = wapp.ActiveDocument.Tables(1)

'Call wapp.ActiveDocument.Tables.Add(wapp.Application.Selection.Range, 1, 7, 1, 0)

 Call wapp.ActiveDocument.Tables.Add(wapp.Application.Selection.Range, NumRows:=1, NumColumns:= _
        7, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
        wdAutoFitFixed)
        
    With wapp.Selection.Tables(1)
        If .Style <> "网格型" Then
            .Style = "网格型"
        End If
        .ApplyStyleHeadingRows = True
        .ApplyStyleLastRow = False
        .ApplyStyleFirstColumn = True
        .ApplyStyleLastColumn = False
        .ApplyStyleRowBands = True
        .ApplyStyleColumnBands = False
    End With
'Selection.TypeText Text:="d ds ds ds ds ds sd "

wapp.ActiveDocument.Tables(1).Cell(i, 1).Range.InsertAfter c
wapp.ActiveDocument.Tables(1).Cell(i, 2).Range.InsertAfter w
wapp.ActiveDocument.Tables(1).Cell(i, 3).Range.InsertAfter "20:00"
wapp.ActiveDocument.Tables(1).Cell(i, 4).Range.InsertAfter "上传医保数据,处理his系统故障"
wapp.ActiveDocument.Tables(1).Cell(i, 5).Range.InsertAfter q
wapp.ActiveDocument.Tables(1).Cell(i, 6).Range.InsertAfter time
wapp.ActiveDocument.Tables(1).Cell(i, 7).Range.InsertAfter "liuchang"


i = i - 1
wapp.ActiveDocument.Tables(1).Cell(i, 4).Width = 100 'Range.InsertAfter "上传医保数据,处理his系统故障"

End Sub

Private Sub Command2_Click()
Dim day2 As Integer
Dim day4 As String

Set wdoc = wapp.Documents.Open("C:\Users\Administrator\Desktop\新建 Microsoft Word 文档 (4).docx")
wapp.Visible = True
wapp.Selection.EndKey unit:=wdStory
day2 = Format(Now, "dd")

If day2 = 8 Then
wapp.Selection.EndKey unit:=wdStory
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
 Call wapp.ActiveDocument.Tables.Add(wapp.Application.Selection.Range, NumRows:=1, NumColumns:= _
        4, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
        wdAutoFitFixed)
    With wapp.Selection.Tables(1)
        If .Style <> "网格型" Then
            .Style = "网格型"
        End If
        .ApplyStyleHeadingRows = True
        .ApplyStyleLastRow = False
        .ApplyStyleFirstColumn = True
        .ApplyStyleLastColumn = False
        .ApplyStyleRowBands = True
        .ApplyStyleColumnBands = False
    End With
    wapp.ActiveDocument.Tables(1).Cell(i + 1, 1).Width = 103
     wapp.ActiveDocument.Tables(1).Cell(i + 1, 2).Width = 130
      wapp.ActiveDocument.Tables(1).Cell(i + 1, 3).Width = 102
       wapp.ActiveDocument.Tables(1).Cell(i + 1, 4).Width = 130
       wapp.ActiveDocument.Tables(1).Cell(i + 1, 1).Height = 60
       wapp.ActiveDocument.Tables(1).Cell(i + 1, 2).Height = 60
       wapp.ActiveDocument.Tables(1).Cell(i + 1, 3).Height = 60
       wapp.ActiveDocument.Tables(1).Cell(i + 1, 4).Height = 60
       wapp.ActiveDocument.Tables(1).Cell(i + 1, 1).Range.InsertAfter "pizhunren" ' = 103
       wapp.ActiveDocument.Tables(1).Cell(i + 1, 3).Range.InsertAfter "shenheren" '= 103
       
       wapp.Selection.EndKey unit:=wdStory
       day4 = wdoc.Tables(1).Cell(6, 6).Range.Text
       Selection.TypeText Text:=Left(day4, Len(day4) - 4)
       'ActiveDocument.BuiltInDocumentProperties(wdPropertyLines).Value
       
    End If
End Sub

Private Sub Form_Load()

'i = 1
Dim day As Integer
day = Format(Now, "dd")
Text1.Text = day
If day = 8 Then
Set wdoc = wapp.Documents.Open("C:\Users\Administrator\Desktop\新建 Microsoft Word 文档 (4).docx")
wapp.Visible = True
wapp.Selection.EndKey unit:=wdStory

 Selection.Font.Name = "Adobe 黑体 Std R"
    Selection.Font.Size = 22

    Selection.TypeText Text:="值班"
   
    Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter














'————————————————————————————————————————————————————————表
Set wdoc = wapp.Documents.Open("C:\Users\Administrator\Desktop\新建 Microsoft Word 文档 (4).docx")
'wapp.Visible = True
wapp.Selection.EndKey unit:=wdStory





'Dim table
'Set table = wapp.ActiveDocument.Tables(1)
'i = i - 1
 Selection.Font.Name = "宋体"
    Selection.Font.Size = 10
Call wapp.ActiveDocument.Tables.Add(wapp.Application.Selection.Range, 1, 7, 1, 0)


'wapp.ActiveDocument.Tables(1).Cell(i, 4).Width = 100 'Range.InsertAfter "上传医保数据,处理his系统故障"
wapp.ActiveDocument.Tables(1).Cell(1, 1).Range.InsertAfter "c"
wapp.ActiveDocument.Tables(1).Cell(1, 2).Range.InsertAfter "w"
wapp.ActiveDocument.Tables(1).Cell(1, 3).Range.InsertAfter "20:00"
wapp.ActiveDocument.Tables(1).Cell(1, 4).Range.InsertAfter "上传医保数据,处理his系统故障"
wapp.ActiveDocument.Tables(1).Cell(1, 4).Width = 100
wapp.ActiveDocument.Tables(1).Cell(1, 5).Range.InsertAfter "q"
wapp.ActiveDocument.Tables(1).Cell(1, 6).Range.InsertAfter "time"
wapp.ActiveDocument.Tables(1).Cell(1, 7).Range.InsertAfter "liuchang"
End If







End Sub

Private Sub Timer1_Timer()
Label1.Caption = Format(Now, "yyyy-mm-dd")

End Sub
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
全自动排班使用说明 1、在设置好年份与头。 "2、每年1月1日,在中按一个排班周期设置好人员名单,将自动生成全年排班,   第一行就是1月1日上班人员,如使用该时不是1月1日,可以通过调整中   的排班次序来获得之后日期的正确排班。单元格内的多行人员代当天几个班   (如三行就是早中晚),当天增加一个班,就在人员单元格内按[Alt-Enter]换行。" 3、在中,请自行增加本年的节日,假日会以红底黑字增亮显示 4、在中设置好班次与工时。 5、在中可以自动统计每人每月或全年的工作量 "6、对于不规则情况的排班,如换班,可以在当月人员名单中手动更改,另外,如果每天   的班次大于三个,会出现单元格显示不下的情况,这时可以用快捷键来修改字体大小。" "7、快捷键:   Ctrl-q 所有保护状态,只有人员显示栏可以更改   Ctrl-e 取消所有的保护状态,所有栏都可编辑   Ctrl-r 所有人员名称字体加大   Ctrl-t 所有人员名称字体减小 Ctrl-p 下打印排班 Alt-F4 退出EXECL" "8、注意事项:理论上没有限制,但由于单元格显示宽高度有限(字体太小影响显示效果),       本建议适用一个班最多三人,一天最多四个班上班(四行)的情况,不符合       该条件的可以使用《排班(考勤版)》解决。"

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值