Forum » Programska oprema » Word Visual Basic -shranjevanje posamicne strani
Word Visual Basic -shranjevanje posamicne strani
smeskec001 ::
Pozdravljeni.
Imam wordov dokument 100 strani. Vsaka stran je bila generirana avtomaticno. Ker so dokumenti razlicni bi moral sedaj vsako stran shraniti posebaj ker to vzame veliko casa me zanima ce ima program ( visual basic) ki bi pogleda v excel tabelo in vsaki strani dodelil svojo ime in jo shrani.
HVALA!
Imam wordov dokument 100 strani. Vsaka stran je bila generirana avtomaticno. Ker so dokumenti razlicni bi moral sedaj vsako stran shraniti posebaj ker to vzame veliko casa me zanima ce ima program ( visual basic) ki bi pogleda v excel tabelo in vsaki strani dodelil svojo ime in jo shrani.
HVALA!
- spremenil: smeskec001 ()
smeskec001 ::
Evo nasel sem VBA kodo sedaj, se mi manjka samo kako linkat z excel tabelo. Vrstica
Generate the file name
fn = "Page" + CStr(idx) + ".doc"
Sub SavePagesAsDoc()
Dim orig As Document
Dim page As Document
Dim numPages As Integer
Dim idx As Integer
Dim fn As String
' Keep a reference to the current document.
Set orig = ActiveDocument
' Calculate the number of pages
numPages = ActiveDocument.Range.Information(wdActiveEndPageNumber)
For idx = 1 To numPages
' Make sure the document is active
orig.Activate
' Go to the page with index idx
Selection.GoTo What:=wdGoToPage, Name:=idx
' Select the current page
Selection.GoTo What:=wdGoToBookmark, Name:="\page"
' Copy the selection
Selection.Copy
' Create a new document
Set page = Documents.Add
' Activate it
page.Activate
' Paste the selection
Selection.Paste
' Generate the file name
fn = "Page" + CStr(idx) + ".doc"
' Save the document as Word 97-2003
page.SaveAs FileName:=fn, FileFormat:=wdFormatDocument, AddToRecentFiles:=False
' Close the document
page.Close
Next
End Sub
Generate the file name
fn = "Page" + CStr(idx) + ".doc"
Sub SavePagesAsDoc()
Dim orig As Document
Dim page As Document
Dim numPages As Integer
Dim idx As Integer
Dim fn As String
' Keep a reference to the current document.
Set orig = ActiveDocument
' Calculate the number of pages
numPages = ActiveDocument.Range.Information(wdActiveEndPageNumber)
For idx = 1 To numPages
' Make sure the document is active
orig.Activate
' Go to the page with index idx
Selection.GoTo What:=wdGoToPage, Name:=idx
' Select the current page
Selection.GoTo What:=wdGoToBookmark, Name:="\page"
' Copy the selection
Selection.Copy
' Create a new document
Set page = Documents.Add
' Activate it
page.Activate
' Paste the selection
Selection.Paste
' Generate the file name
fn = "Page" + CStr(idx) + ".doc"
' Save the document as Word 97-2003
page.SaveAs FileName:=fn, FileFormat:=wdFormatDocument, AddToRecentFiles:=False
' Close the document
page.Close
Next
End Sub
Vredno ogleda ...
Tema | Ogledi | Zadnje sporočilo | |
---|---|---|---|
Tema | Ogledi | Zadnje sporočilo | |
» | VB.net Excel v TifOddelek: Programiranje | 1144 (1043) | saule |
» | Word 2003 VBA problemOddelek: Programska oprema | 1036 (923) | mimax |
» | VISUAL BASIC - Makro v wordu - prenos podatkov iz tabel v excelOddelek: Programiranje | 2883 (2745) | FlashM |
» | access -> word ali excelOddelek: Programska oprema | 1222 (1163) | zavajon |
» | [excel]duplikatiOddelek: Programiranje | 1472 (1399) | baksuz |