Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it
    Registrato dal
    Apr 2009
    Messaggi
    191

    [VB.NET]Tabella Word...

    Ciao a tutti, mediante questo codice genero una tabella word...

    codice:
    Imports Word = Microsoft.Office.Interop.Word
    
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim oWord As Word.Application
            Dim oDoc As Word.Document
            Dim oTable As Word.Table
            Dim oPara1 As Word.Paragraph, oPara2 As Word.Paragraph
            Dim oPara3 As Word.Paragraph, oPara4 As Word.Paragraph
            Dim oRng As Word.Range
            Dim oShape As Word.InlineShape
            Dim oChart As Object
            Dim Pos As Double
    
            'Start Word and open the document template.
            oWord = CreateObject("Word.Application")
            oWord.Visible = True
            oDoc = oWord.Documents.Add
    
            
            
    
            'Insert a 5 x 2 table, fill it with data, and change the column widths.
            oTable = oDoc.Tables.Add(oDoc.Bookmarks.Item("\endofdoc").Range, 5, 2)
            oTable.Range.ParagraphFormat.SpaceAfter = 6
            For r = 1 To 5
                For c = 1 To 2
                    oTable.Cell(r, c).Range.Text = "r" & r & "c" & c
                Next
            Next
            oTable.Columns.Item(1).Width = oWord.InchesToPoints(2)   'Change width of columns 1 & 2
            oTable.Columns.Item(2).Width = oWord.InchesToPoints(3)
    
    
            Me.Close()
    
        End Sub
    End Class
    Il problema consiste nel fatto che tale tabella non ha nessuno stile, e va impostato manualmente...
    Vorrei sapere: come faccio da codice ad impostare lo stile alla tabella?

    Un'altra cosa: sempre da codice, come posso passare alla pagina successiva del file di word?

    Grazie mille a tutti...

  2. #2
    Selection.InsertBreak Type:=wdPageBreak
    Selection.Tables(1).Style = "Sfondo chiaro"

    fai una cosa, prova ad utilizzare le macro e vedi come diventa facile capire come sistemare le cose
    ChromeOS.eu tutto su Chrome OS!
    HTML5 Answer Il 3D nel browser è arrivato! Sviluppa la tua app 3D per il browser!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.