메모장에 저장 한 코드입니다. Excel.Applications를 변경해야합니까? Excel에서 코드를 실행하는 메모장의 VBA
Option Explicit
Dim xlApp
Dim xlBook
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open("H:\shane.xlsm", 0, True)
xlApp.Run "Email"
xlBook.close
xlApp.Quit
Set xlBook = Nothing
Set xlApp = nothing
이
내가 이메일을 보낼 수있는 코드와 내가 테스트 할 때 그것을 잘 작동하고 나에게 이메일을 보내드립니다.Option Explicit
Const strTo As String = "[email protected]"
Const strCC As String = "" '<~~ change "[email protected]" to "" if you do not want to CC
Const strBCC As String = "" '<~~ change "[email protected]" to "" if you do not want to BCC
Sub Email()
Dim OutApp As Object, OutMail As Object
Dim strbody As String, strSubject As String
strSubject = "Hello World"
strbody = "This is the message for the body"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = strTo
.CC = strCC
.BCC = strBCC
.Subject = "This is the Subject line"
.Body = strbody
.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
코드를 게시하면 실패한 것을 보여줍니다. –
매크로를 메모장 대신 Excel 통합 문서에 저장하십시오. – GolezTrol
다른 woorkbook에서 매크로를 제어하는 가장 쉬운 방법입니까? –