By gwentaylor Dé Luain, 29 Márta 2021
Posted in Excel
Freagraí 0
Is maith 0
tuairimí 2.8K
Vótaí 0
Dia duit Tá do chód á úsáid agam chun raon Excel a sheoladh mar cheangaltán ríomhphoist ach faigh earráid ama rite má chuirim an raon ar ceal. An bhfuil cód is féidir liom a chur leis nó bosca msg le do thoil chun é seo a chosc? Cód buíochas thíos.

Fo-Raon Send()
Dim xFile Mar Teaghrán
Dim xFormat Chomh fada
Dim Wb Mar Leabhar Oibre
Dim WB2 Mar Leabhar Oibre
Dim Ws Mar Bhileog Oibre
Dim FilePath As Teaghrán
Dim ComhadName Mar Teaghrán
Dim OutlookApp Mar Réad
Dim OutlookMail Mar Réad
Dim WorkRng Mar Raon
xTitleId = "Sampla"
Set WorkRng = Iarratas.Roghnú
Socraigh WorkRng = Application.InputBox("Raon", xTitleId, WorkRng.Address, Cineál:=8)

Application.ScreenUpdating = Bréagach
Application.DisplayAlerts = Bréagach
Socraigh Wb = Application.ActiveWorkbook
Wb.Bileoga Oibre.Cuir
Socraigh Ws = Application.ActiveSheet
WorkRng.Copy Ws.Cells(1, 1)
Ws.Copy
Socraigh Wb2 = Application.ActiveWorkbook
Roghnaigh Cás Wb.FileFormat
Cás xlOpenXML Workbook:
    xFile = ".xlsx"
    xFormat = xlOpenXMLLeabhar Oibre
Cás xlOpenXMLLeabhar OibreMacro Cumasaithe:
    Má Wb2.HasVBProject Ansin
        xFile = ".xlsm"
        xFormat = xlOpenXMLWorkbookMacroEnable
    Eile
        xFile = ".xlsx"
        xFormat = xlOpenXMLLeabhar Oibre
    Deireadh Má
Cás Excel8:
    xFile = ".xls"
    xFormat = Excel8
Cás xlExcel12:
    xFile = ".xlsb"
    xFormat = xlExcel12
Roghnaigh Roghnaigh
FilePath = Timpeallacht$("temp") & "\"
FileName = Wb.Name & Formáid(Anois, "dd-mmm-yy h-mm-ss")
Socraigh OutlookApp = CreateObject ("Outlook.Application")
Socraigh OutlookMail = OutlookApp.CreateItem(0)
Wb2.SaveAs FilePath & FileName & xFile, FileFormat:=xFormat
Le OutlookMail
    .To = "gtest@email.com"
    .CC = ""
    .BCC = ""
    .Subject = "Tástálacha"
    . Comhlacht = " Dia duit ."
    .Ceangail.Cuir Wb2.FullName leis
    .Seol
Deireadh Le
Wb2.Dún
Maraigh FilePath & FileName & xFile
Socraigh OutlookMail = Ní dhéanfaidh aon ní
Socraigh OutlookApp = Ní dhéanfaidh aon ní
Ws.Scrios
Application.DisplayAlerts = Fíor
Feidhmchlár.ScreenUpdating = Fíor
Fo Deireadh
 
Féach ar an bPost Iomlán