Note: The other languages of the website are Google-translated. Back to English
Logáil isteach  \/ 
x
or
x
Cláraigh  \/ 
x

or

Conas ríomhphost a sheoladh trí Outlook nuair a shábháiltear leabhar oibre in Excel?

Tá an t-alt seo ag caint ar r-phost a sheoladh trí Outlook nuair a shábhálfar leabhar oibre ar leith in Excel. Déan mar a léiríonn an rang teagaisc le do thoil.

Seol r-phost trí Outlook nuair a shábhálfar leabhar oibre le cód VBA


Seol r-phost trí Outlook nuair a shábhálfar leabhar oibre le cód VBA


Chun ríomhphost a sheoladh trí Outlook nuair a shábhálfar an leabhar oibre in Excel, déan mar a leanas le do thoil.

1. Sábháil an leabhar oibre mar Leabhar Oibre Macra-Chumasaithe Excel ar dtús. Cliceáil Comhad > Sábháil Mar. Sa an Sábháil Mar bosca dialóige, roghnaigh fillteán chun an leabhar oibre a shábháil, ainmnigh é sa bhosca Ainm comhaid, roghnaigh Leabhar Oibre Macra-Chumasaithe Excel ó na Ach amháin mar chineál liosta anuas, agus ansin cliceáil ar an Sábháil cnaipe. Féach an pictiúr:

2. Oscail Leabhar Oibre Macra-Chumasaithe Excel a shábháil tú díreach anois, brúigh an Eile + F11 eochracha ag an am céanna chun an Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

2. Sa Microsoft Visual Basic d’Fheidhmchláir fuinneog, cliceáil faoi dhó le do thoil An Leabhar Oibre seo sa bharra ar chlé, ansin cóipeáil agus greamaigh an cód VBA thíos sa An Leabhar Oibre seo fuinneog cód. Féach an pictiúr:

Cód VBA: Seol r-phost nuair a shábhálfar an leabhar oibre

Private Sub Workbook_AfterSave(ByVal Success As Boolean)
'Updated by Extendoffice 20181102
    Dim xOutApp As Object
    Dim xMailItem As Object
    Dim xName As String
    On Error Resume Next
    Set xOutApp = CreateObject("Outlook.Application")
    Set xMailItem = xOutApp.CreateItem(0)
    xName = ActiveWorkbook.FullName
    With xMailItem
        .To = "Email Address"
        .CC = ""
        .Subject = "The workbook has been saved"
        .Body = "Hi," & Chr(13) & Chr(13) & "File is now updated."
        .Attachments.Add xName
        .Display
       '.send
    End With
    Set xMailItem = Nothing
    Set xOutApp = Nothing
End Sub

nótaí: Cuir an Seoladh ríomhphoist le seoladh ríomhphoist an fhaighteora ar aon dul .To = "Seoladh Ríomhphoist", agus athraigh an Cc, Ábhar chomh maith le réimsí coirp sa chód VBA de réir mar a theastaíonn uait.

3. Brúigh an Eile + Q eochracha ag an am céanna chun an Microsoft Visual Basic d’Fheidhmchláir fhuinneog.

As seo amach, nuair a dhéanfaidh tú an leabhar oibre a nuashonrú agus a shábháil, cruthófar r-phost go huathoibríoch agus an leabhar oibre nuashonraithe ceangailte leis. Cliceáil le do thoil ar an Seol cnaipe chun an ríomhphost a sheoladh. Féach an pictiúr:

nótaí: Níl an cód VBA ag obair ach nuair a úsáideann tú Outlook mar do chlár ríomhphoist.


Earraí gaolmhara:


Na hUirlisí Táirgiúlachta Oifige is Fearr

Réitíonn Kutools for Excel an chuid is mó de do chuid Fadhbanna, agus Méadaíonn sé do Tháirgiúlacht 80%

  • Athúsáid: Cuir isteach go tapa foirmlí casta, cairteacha agus aon rud a d'úsáid tú roimhe seo; Cealla a Chriptiú le pasfhocal; Cruthaigh Liosta Ríomhphoist agus seol ríomhphoist ...
  • Barra Foirmle Super (cuir línte iolracha téacs agus foirmle in eagar go héasca); Leagan Amach Léitheoireachta (líon mór cealla a léamh agus a chur in eagar go héasca); Greamaigh go dtí an Raon Scagtha...
  • Cumaisc Cealla / Sraitheanna / Colúin gan Sonraí a chailleadh; Ábhar Cealla Scoilt; Comhcheangail Sraitheanna / Colúin Dúblacha... Cill Dúblach a Chosc; Déan comparáid idir Ranganna...
  • Roghnaigh Dúblach nó Uathúil Sraitheanna; Roghnaigh Blank Rows (tá na cealla uile folamh); Aimsigh Super agus Fuzzy Aimsigh i go leor Leabhar Oibre; Roghnaigh go randamach ...
  • Cóip Díreach Cealla Il gan tagairt fhoirmle a athrú; Tagairtí Cruthaigh Auto chuig Bileoga Il; Cuir Urchair isteach, Boscaí Seiceála agus go leor eile ...
  • Sliocht Téacs, Cuir Téacs leis, Bain de réir Poist, Bain Spás; Subtotals Paging a chruthú agus a phriontáil; Tiontaigh Idir Ábhar Cealla agus Tráchtanna...
  • Scagaire Super (scéimeanna scagaire a shábháil agus a chur i bhfeidhm ar bhileoga eile); Ard-Sórtáil de réir míosa / seachtaine / lae, minicíocht agus níos mó; Scagaire Speisialta le cló trom, iodálach ...
  • Comhcheangail Leabhair Oibre agus Bileoga Oibre; Cumaisc Táblaí bunaithe ar eochaircholúin; Roinn Sonraí i Ilbhileoga; Baisc Tiontaigh xls, xlsx agus PDF...
  • Níos mó ná 300 gné chumhachtach. Tacaíochtaí Office / Excel 2007-2019 agus 365. Tacaíonn sé le gach teanga. Imscaradh éasca i d’fhiontar nó d’eagraíocht. Gnéithe iomlána triail saor in aisce 30 lá. Ráthaíocht ar ais airgid 60 lá.
cluaisín kte 201905

Tugann Tab Oifige comhéadan Tabbed chuig Office, agus Déan Do Obair i bhfad Níos Éasca

  • Cumasaigh eagarthóireacht agus léamh tabbed i Word, Excel, PowerPoint, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méadaíonn do tháirgiúlacht 50%, agus laghdaíonn sé na céadta cad a tharlaíonn nuair luch duit gach lá!
bun officetab
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    florin · 1 years ago
    Dear All, can some one help me, I'm a novice in VBA coding, I have made some modification, but how can I do so send email if the workbook is saved, and if user name is different, like if user name of the station is glade2 then send email if the workbook is saved, else do not send.

    Thank you so much for your support
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi florin,
      Didn't get your point. What does your username represent?
      • To post as a guest, your comment is unpublished.
        Florin Dan · 1 years ago
        Hi crystal, thank you for your reply, usernane is enviroment usernane, and i have done it, i did use a if function and exit sub.
        Thank you so much.
  • To post as a guest, your comment is unpublished.
    Brent · 1 years ago
    Hello - How can I include cell data in the email "cc" field?
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Brent,
      Supposing you want to include the value in cell a7 in the email "cc" field, please try the below VBA.

      Private Sub Workbook_AfterSave(ByVal Success As Boolean)
      'Updated by Extendoffice 20200628
      Dim xOutApp As Object
      Dim xMailItem As Object
      Dim xName As String
      On Error Resume Next
      Set xOutApp = CreateObject("Outlook.Application")
      Set xMailItem = xOutApp.CreateItem(0)
      xName = ActiveWorkbook.FullName
      With xMailItem
      .To = "Email Address"
      .CC = Range("a7").Value
      .Subject = "The workbook has been saved"
      .Body = "Hi," & Chr(13) & Chr(13) & "File is now updated."
      .Attachments.Add xName
      .Display
      '.send
      End With
      Set xMailItem = Nothing
      Set xOutApp = Nothing
      End Sub
  • To post as a guest, your comment is unpublished.
    Lena · 1 years ago
    Hi! Thanks a lot for this guideline :-) I would like to do something more in this code - send an email based on the countries. It means that I have to create commands with if and select. Right? I have already delete the attachment from email. I would like to add the link with path into folder instead. But when macro run, command is not valid :-(
    I appreciate each help how to add it there.
  • To post as a guest, your comment is unpublished.
    Mike · 1 years ago
    Is there a way to have the automated email be auto encrypted?
    • To post as a guest, your comment is unpublished.
      crystal · 1 years ago
      Hi Mike,
      Sorry can't help to solve this problem. Thank you for your comment.
  • To post as a guest, your comment is unpublished.
    mayle4pam · 2 years ago
    How would this be handled for an Office 365 document. It is automatically saving.
  • To post as a guest, your comment is unpublished.
    Chris · 2 years ago
    Hi, nice article! One thing ive been trying to achieve with this is to attach the current state of the workbook to the email.

    At the moment, it only sends the original state of the file and doesnt include any changes the user would have made.

    Any ideas on how to implement this using a macro?
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Hi Chris,
      The code has been updated with the problem solved, please have a try. Thank you for your comment.
      • To post as a guest, your comment is unpublished.
        Tin Hwee Lee · 2 years ago
        Hi Chris,

        I have chanced upon the same issue.
        Currently the codes are used in the "beforesave" module.
        Which means that the email will send the spreadsheet that is before saved.

        There is another module "aftersave".
        I applied the code in this module and it worked like a charm.
  • To post as a guest, your comment is unpublished.
    Bob · 2 years ago
    Dear all, I would like to ask how to attach functional link to certain folder on server, if I paste the link, it appears in the workbook just like plain text and so it doensn't work in received e-mail, how can I turn it into link, so recepiants can click on it?
    I would like to use this way instead sending enclosed excel file.
    Thanks for advice
    • To post as a guest, your comment is unpublished.
      Grant · 2 years ago
      I put this in the body of the email and it worked for me...
      "file:///Z:\dir1\dir2\dir3\Test1.xlsm"
    • To post as a guest, your comment is unpublished.
      crystal · 2 years ago
      Hi Robert,
      Sorry can’t help with this, welcome to post any question about Excel to our forum: https://www.extendoffice.com/forum.html. You will get more Excel supports from our professional or other Excel fans.
  • To post as a guest, your comment is unpublished.
    Antonio · 3 years ago
    Gracias. Consulta: utilizando esta misma rutina, como podría enviar el correo a un correo específico dependiendo el valor de otra celda?
  • To post as a guest, your comment is unpublished.
    Jermaine · 3 years ago
    How to automate the email notification in VBA based on Date range, without having to see the pop up for security permission to allow VBA to send the email.