2013-08-13 2 views
0

다른 데이터와 함께 시트를 엑셀 시트로 보내고 싶습니다. 정상적인 내보내기를 수행 할 수 있습니다. 또한 문서에서 파일 위치로 첨부 파일의 압축을 풉니 다. 이제해야 할 일은 Excel 셀에 첨부하는 것입니다.Lotus Notes : 첨부 파일을 엑셀 시트로 내보내기

Sub Click(Source As Button) 
    Dim ws As New NotesUIWorkspace 
    Dim uiView As NotesUIView 
    Dim doc As NotesDocument 
    Dim docCol As NotesDocumentCollection 

    Set uiView = ws.CurrentView 
    Set docCol = uiView.Documents 

    Set doc = docCol.GetFirstDocument 
    Dim xlApp As Variant 
    Dim xlsheet As Variant 
    Dim rtitem As Variant 
    Dim Ol As Variant 
    maxcols= 2 
    Set xlApp = CreateObject("Excel.Application") 
    xlApp.StatusBar = "Creating WorkSheet. Please be patient..." 
    xlApp.Visible = True 
    xlApp.Workbooks.Add 
    xlApp.ReferenceStyle = 2 
    rows = 1 
    cols = 1 
    Set xlsheet = xlApp.Workbooks(1).Worksheets(1) 

    xlsheet.Cells(rows,1).Value = "Created By" 
    xlsheet.Cells(rows,2).Value = "File/Attachment" 
    cols=1 
    rows=2 
    While Not doc Is Nothing 

     xlsheet.Cells(rows,1).Value = doc.CreatedBy(0) 
     Set rtitem = doc.GetFirstItem("FileUpload") 
     If (rtitem.Type = RICHTEXT) Then 
      Forall o In rtitem.EmbeddedObjects 
       If (o.Type = EMBED_ATTACHMENT) Then 
        Call o.ExtractFile ("d:\temp\" & Cstr(doc.FileName(0))) 
       End If 
      End Forall 
      xlsheet.Cells(rows,2).select 

     ' xlsheet.Cells(rows,2).OLEObjects.Add Cstr(doc.FileName(0)), "d:\temp\" & Cstr(doc.FileName(0)), , True, , , Cstr(doc.FileName(0))  
      'Set Ol = xlApp.OLEObjects.Add(Cstr(doc.FileName(0)), "d:\temp\" & Cstr(doc.FileName(0)), True, False) 
      xlsheet.OLEObjects.Add("", "d:\temp\" & Cstr(doc.FileName(0)), False, False).Select 


     End If 

     Set doc = docCol.GetNextDocument(doc) 
     rows=rows+1 
     cols=1 
    Wend 
    xlApp.Rows("1:1").Select 
    xlApp.Selection.Font.Bold = True 
    xlApp.Selection.Font.Underline = True 
    xlApp.Range(xlsheet.Cells(1,1), xlsheet.Cells(rows,maxcols)).Select 
    xlApp.Selection.Font.Name = "Arial" 
    xlApp.Selection.Font.Size = 8 
    xlApp.Selection.Columns.AutoFit 
    With xlApp.Worksheets(1) 
     .PageSetup.Orientation = 2 
     .PageSetup.centerheader = "Report - Confidential" 
     .Pagesetup.RightFooter = "Page &P" & Chr$(13) & "Date: &D" 
     .Pagesetup.CenterFooter = "" 
    End With 
    xlApp.ReferenceStyle = 1 
    xlApp.Range("A1").Select 
    xlApp.StatusBar = "Importing Data from Lotus Notes Application was Completed." 
End Sub 

의견을 공유하십시오.

감사합니다, 오류의 경우 이후 Himanshu

답변

0

는, 내가 일반적으로 VBA를 사용하여 Excel 시트 내에서 가능한 한 많은 프로그램을 시도, 문제가 무엇인지를 결정하는 것은 매우 어렵습니다. VBA에서 작동하면 코드를 Excel로 포팅합니다.

나는 이것을 여기에서하는 것이 좋습니다. 이것은 실제로 Lotus Notes 질문이 아니라 VBA 질문입니다.

0

나는 Andrew와 동의 할 것이다. 스프레드 시트에 파일을 첨부/임베드하고 내보내기 파일을 만들지 말고 메모로 스프레드 시트를 열어 첨부 파일을 만듭니다. 얼마나 많은 스프레드 시트가 스프레드 시트에 첨부 될 것입니까?

뒤로 물러나십시오 - 이제 내보내기 파일을 만들 수 있습니다. 서식있는 텍스트 필드가있는 새 문서를 만든 다음 새로 만든 내보내기 파일을 만들 때 첨부하십시오. 그런 다음이 새 문서를보기에 표시하십시오. 원격 사용자를 위해이 작업을 수행하는 경우 첨부 파일이있는 문서를 중앙 DB에 전자 메일로 보낼 수 있습니다. 그것은 데이터가 끝날 곳과 표시 방법에 달려 있습니다. 각각의 비용에는 가능한 많은 선택이 있습니다.