使用本网站上其他人的很多以前的问题,我创建了一些对我来说非常有用的代码,只有其中有些错误,因为当我激活vba脚本时,excelsheet尤其是这些脚本是非常慢。
也许这是由于不同的子脚本引起的吗?
Private Sub CommandButton1_Click()
Dim OutlookApp As Object
Dim Mess As Object, Recip, Datum, Aanhef, School, Leerlingen, Bezoekadres, Contact, Begintijd, Eindtijd
Recip = [k10].Value
n = SpinButton1.Value + 1
Datum = Format(Cells(n, 2), "dddd d mmmm yyyy")
Aanhef = Cells(n, 10)
School = Cells(n, 3)
Bezoekadres = Cells(n, 5)
Contact = Cells(n, 6)
Leerlingen = Cells(n, 12)
Begintijd = Format(Cells(n, 7), "hh:mm")
Eindtijd = Format(Cells(n, 8), "hh:mm")
Set OutlookApp = CreateObject("Outlook.Application")
Set Mess = OutlookApp.CreateItem(olMailItem)
With Mess
.Subject = "Afspraakherinnering op " & Datum & " op het " & School
.HTMLBody = " Beste " & Aanhef "
.To = Recip
.Display
'.send
End With
End Sub
Private Sub CommandButton3_Click()
Dim objWorksheet As Excel.Worksheet
Dim Mess As Object, Recip, Datum, Aanhef, School, Leerlingen, Bezoekadres, Contact, Begintijd, Eindtijd
Dim objOutlookApp As Outlook.Application
Dim objCalendar As Outlook.Folder
Dim objSchoolEvent As Outlook.AppointmentItem
Dim objRecurrencePattern As Outlook.RecurrencePattern
n = SpinButton1.Value + 1
Set objWorksheet = ThisWorkbook.Sheets(1)
nLastRow = objWorksheet.Range("A" & objWorksheet.Rows.Count).End(xlUp).Row
Set objOutlookApp = CreateObject("Outlook.Application")
Set objCalendar = objOutlookApp.Session.GetDefaultFolder(olFolderCalendar)
Set objSchoolEvent = objCalendar.Items.Add("IPM.Appointment")
With objSchoolEvent
.Subject = Cells(n, 3)
.AllDayEvent = False
.start = Cells(n, 2) + Cells(n, 7)
.End = Cells(n, 2) + Cells(n, 8)
.Location = Cells(n, 5)
.Body = Cells(n, 14)
.Save
End With
End Sub
Private Sub SpinButton1_Change()
n = SpinButton1.Value + 1
Range("C38").Value = Cells(n, 3)
Range("C39").Value = Format(Cells(n, 2), "dddd d mmmm yyyy")
Range("C40").Value = Format(Cells(n, 7), "hh:mm")
Range("C41").Value = Format(Cells(n, 8), "hh:mm")
End Sub
Private Sub CommandButton2_Click()
Dim OutlookApp As Object
Dim Mess As Object, Recip, Datum, Aanhef, School, Leerlingen, Bezoekadres, Contact, Begintijd, Eindtijd
Recip = [k10].Value
n = SpinButton1.Value + 1
Datum = Format(Cells(n, 2), "dddd d mmmm yyyy")
Aanhef = Cells(n, 10)
School = Cells(n, 3)
Bezoekadres = Cells(n, 5)
Contact = Cells(n, 6)
Leerlingen = Cells(n, 12)
Begintijd = Format(Cells(n, 7), "hh:mm")
Eindtijd = Format(Cells(n, 8), "hh:mm")
Set OutlookApp = CreateObject("Outlook.Application")
Set Mess = OutlookApp.CreateItem(olMailItem)
With Mess
.Subject = "Afspraakherinnering op " & Datum & " op het " & School
.HTMLBody = " Beste " & Aanhef & ",<br><br>"
.To = Recip
.Display
'.send
End With
End Sub
答案 0 :(得分:0)
您可以尝试调用这些潜艇。首先先调用“ SpeedupProcessing”,然后在完成所有处理后再调用“ Back_to_Normal”。
double doub = 543.345671;
int num1 = (int) doub; //543
int num2 = getNumAfterDecimal(doub-num1); //return 345671