Tip: Mae ieithoedd eraill yn Google-Cyfieithu. Gallwch ymweld â'r English fersiwn o'r ddolen hon.
Mewngofnodi
x
or
x
x
cofrestr
x

or

Sut i greu apwyntiad o ddata Excel?

Yn rhagdybio, mae gennych chi bwrdd o ddata penodi mewn taflen waith Excel fel y dangosir y sgrin ganlynol, nawr, rydych am fewnfudo'r data hyn i mewn i galendr Outlook. Sut allech chi ddelio â'r swydd hon yn gyflym?

data export excel excel i benodi 1

Creu apwyntiadau o ddata Excel gyda chod VBA


Creu apwyntiadau o ddata Excel gyda chod VBA

I greu apwyntiadau o ddata Excel, gallwch chi ddefnyddio'r cod VBA canlynol, gwnewch fel hyn:

1. Lansio Outlook a dal i lawr y ALT + F11 allweddi i agor y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr.

2. Cliciwch Mewnosod > Modiwlau, a gludwch y cod canlynol yn y Modiwlau Ffenestr.

Cod VBA: Mewnforio rhagor o ddata i benodi:

Public Sub CreateOutlookApptz()
    Dim xAppointmentItem As Outlook.AppointmentItem
    Dim xNameSpace As Outlook.NameSpace
    Dim xCalendarFld As Outlook.MAPIFolder, xSubFolder As Outlook.MAPIFolder
    Dim xCalendarStr As String
    Dim I As Long
    Dim xFileDialog As FileDialog
    Dim xFilePath As String
    Dim xExcelApp As Excel.Application
    Dim xWb As Workbook
    Dim xWs As Worksheet
    On Error GoTo Err_Execute
    Set xExcelApp = New Excel.Application
    Set xFileDialog = xExcelApp.FileDialog(msoFileDialogFilePicker)
    With xFileDialog
        .Title = "Select a file"
        .Filters.Add "Microsoft Excel", "*.xlsx"
    End With
    If xFileDialog.Show = 0 Then Exit Sub
    xFilePath = xFileDialog.SelectedItems(1)
    Set xWb = xExcelApp.Workbooks.Open(xFilePath)
    Set xNameSpace = Outlook.Application.Session
    Set xCalendarFld = xNameSpace.GetDefaultFolder(olFolderCalendar)
    I = 2
    Set xWs = xWb.Worksheets.Item(1)
    xCalendarStr = xWb.Name
    If FolderExist(xCalendarFld, xCalendarStr) = False Then
        Set xSubFolder = xCalendarFld.Folders.Add(xCalendarStr, olFolderCalendar)
    Else
        Set xSubFolder = xCalendarFld.Folders(xCalendarStr)
    End If
    Do Until Trim(xWs.Cells(I, 1).Value) = ""
        Set xAppointmentItem = xSubFolder.Items.Add(olAppointmentItem)
        With xAppointmentItem
            .Start = xWs.Cells(I, 5) + xWs.Cells(I, 6)
            .End = xWs.Cells(I, 7) + xWs.Cells(I, 8)
            .Subject = xWs.Cells(I, 1)
            .Location = xWs.Cells(I, 2)
            .Body = xWs.Cells(I, 3)
            .BusyStatus = olBusy
            .ReminderMinutesBeforeStart = xWs.Cells(I, 9)
            .ReminderSet = True
            .Categories = xWs.Cells(I, 4)
            .Save
        End With
        I = I + 1
    Loop
    Set xAppointmentItem = Nothing
    Set olApp = Nothing
    xExcelApp.Quit
    Set xExcelApp = Nothing
    MsgBox "Import successfully!", vbInformation, "Kutools for Outlook"
    Exit Sub
Err_Execute:
    MsgBox "An error occurred - Exporting items to Calendar.", vbInformation, "Kutools for Outlook"
End Sub
Function FolderExist(CalFolder As Folder, FolderName As String) As Boolean
    Dim I As Integer
    Dim xSubFolder As Folder
    For I = 1 To CalFolder.Folders.Count
        Set xSubFolder = CalFolder.Folders.Item(I)
        If xSubFolder.Name = FolderName Then
            FolderExist = True
            Exit Function
        End If
    Next I
End Function

3. Dal yn y Microsoft Visual Basic ar gyfer Ceisiadau ffenestr, cliciwch offer > cyfeiriadau i fynd i'r Cyfeiriadau-Project1 blwch deialog, a siec Llyfrgell Amcanion Microsoft Excel opsiwn gan y Cyfeiriadau ar gael rhestrwch y blwch, gweler y sgrin:

data export excel excel i benodi 2

4. Yna cliciwch OK botwm, nawr, wasg F5 allwedd i redeg y cod hwn, a Dewiswch ffeil dangosir y ffenestr, dewiswch y ffeil excel rydych chi am ei fewnforio i Outlook, gweler y sgrin:

data export excel excel i benodi 3

5. Ac yna cliciwch OK, mae blwch prydlon yn cael ei datgelu fel a ganlyn:

data export excel excel i benodi 4

6. Yna cliciwch OK, mae'r data Excel wedi'i fewnforio i'r calendr fel y lluniau canlynol a ddangosir:

data export excel excel i benodi 5



Kutools ar gyfer Outlook

Mwy na Swyddogaethau Uwch 100 ar gyfer Outlook 2010, 2013, 2016, 2019 a 365

sgrinio kutools ar gyfer rhagolygon bach ar gyfer baner 201812

Mwy o Nodweddion | Lawrlwythiad Am Ddim | $ 39.00 yn unig ar gyfer cannoedd o swyddogaethau

Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.

Be the first to comment.