#contents

*Excel関連情報
**サンプルコード
***各シートをブックに保存する

 Sub Sheet2Book()
     Dim i
     Dim nCount
     Dim strBookName
     strBookName = "E:\home\edu\excel\sheet2book\test_"
     nCount = Sheets.Count
     Dim strSheetName
     For i = 1 To nCount
         strSheetName = Sheets(i).Name
         Sheets(i).Select
         Sheets(i).Copy
         ActiveWorkbook.SaveAs Filename:=strBookName & strSheetName & ".xls"
         ActiveWindow.Close
     Next
 End Sub

*Word関連情報
**サンプルコード
***各ページを文書に保存する

 Sub page2doc()
     Dim i
     Dim nCount
     Dim strDocName
     strDocName = "E:\home\edu\word\test\test_page_"
     nCount = ActiveDocument.Content.Information(wdNumberOfPagesInDocument)
     For i = 1 To nCount
         Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:=i
         Selection.GoTo What:=wdGoToBookmark, Name:="\page"
        
         Selection.Copy
         Documents.Add DocumentType:=wdNewBlankDocument
         Selection.PasteAndFormat (wdPasteDefault)
         Selection.MoveDown Unit:=wdParagraph, Count:=1, Extend:=wdExtend
         ActiveDocument.SaveAs FileName:=strDocName & i
         ActiveWindow.Close
     Next
 End Sub

#comment


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS