2013-09-25 4 views
2

this problem이 해결되지 않는 것으로 보입니다. InfoPath 전자 메일을 자동으로 생성하기위한 다른 옵션을 모색 중입니다.개체가 인계받을 때 CreateObject를 사용하고 사용자 입력을 전달하는 방법은 무엇입니까?

.Submit을 사용하면 다음과 같은 코드가 작동합니다. 기본적으로 InfoPath 창에서 대화 상자의 "보내기"를 눌러야합니다. 내가 바라고

은 기본적으로 얻을 코드가 아래 의사 코드에서 무엇을 할 수있는 방법이있다. .Submit를 호출 할 때 문제는 (documentation here -이 무시로 설정 나는 통과 할 수있는 플래그가/거기처럼 보이지 않는), VBA는 키 입력을 계속하기 위해 (때문에 SendKeys 적어도에, 아래처럼 작동하지 않습니다 기다립니다 Alt + S).

가 나타납니다 확인의 예를 들면 다음 이미지보기 :

enter image description here

나도 (내가 InfoPath는 이메일을 만드는거야 방법을 변경하기 위해 내가 가진 경우에도)이 억제하거나 할 수 있도록하려면

"보내기"키 누르기를 위조하십시오.

Private Sub GenerateInfoPathEmail() 

    Dim mFilePath As String 
    Dim oApp As Object 
    Dim objEmailAdapter As EmailAdapterObject 

    mFilePath = "A:\tmp\testform.xsn" 
    Set oApp = CreateObject("InfoPath.Application") 
    oApp.XDocuments.NewFromSolution (mFilePath) 

    'infopath form has a connection called "email" 
    Set objEmailAdapter = oApp.XDocuments(0).DataAdapters("email") 
    objEmailAdapter.To = "[email protected]" 
    objEmailAdapter.CC = "" 
    objEmailAdapter.Intro = "intro" 
    objEmailAdapter.Subject = "subject" 
    objEmailAdapter.AttachmentType = 1 'xdXmlXns 
    objEmailAdapter.AttachmentFileName = mFilePath 

    'I want to be able to pass through 
    'the silly user input here to basically 
    'hit "send" (alt+s for keyboard shortcut) 
    objEmailAdapter.Submit 
    SendKeys ("%s") ' This obviously won't work because the code waits for user input 


End Sub 

답변

0

나는 거기 appraoch을 테스트 할 수 있도록 InfoPath는 사용하지 않지만, 당신은 필수 필드를 채우고 {tab} 코드 (아래 참조)를 사용하여이 문제를 해결하기 위해 SendKeys 매크로를 사용할 수 있습니다. Tab 키가 사용자 입력 폼의 필드 사이를 이동하기를 바랍니다. 그것은 최고의 생각되지 않을 수도 있습니다

주의의 단어, SendKeys 매크로는 신뢰할 수 있지만, 당신은 문제를 해결하는 또 다른 방법을 찾을 수없는 경우는 시도 가치가있을 수 있습니다.

Sub testSendKeys() 
    Dim SendkeyString As String 

    Application.Wait (3)      'Wait 3 seconds to allow 
               'form to load 
    SendkeyString = "[email protected]"  'Fill in the to field that appears 
               'to be selected by default 
    SendkeyString = SendkeyString & "{tab}"  'Tab to CC field 
    SendkeyString = SendkeyString & "{tab}"  'Tab to BCC field 
    SendkeyString = SendkeyString & "{tab}"  'Tab to Subject field 
    SendkeyString = SendkeyString & "subject" 'Fill in subject details 
    SendkeyString = SendkeyString & "%s"  'Alt-S to send 

    SendKeys (SendkeyString) 
End Sub 
관련 문제