• Lunes 29 de Abril de 2024, 08:11

Autor Tema:  Ayuda-necesito Crear Un Docemento Word Desde Vb  (Leído 1135 veces)

serbc25

  • Nuevo Miembro
  • *
  • Mensajes: 17
    • Ver Perfil
Ayuda-necesito Crear Un Docemento Word Desde Vb
« en: Sábado 10 de Febrero de 2007, 20:34 »
0
Hola a todos:

Tengo que hace run proyecto en vb que cuando pinche sobre el boton imprimir
me abra word con unos determiandos campos de la bd que no existen en el
formulario

Ejemplo

Formulario

ID: 4
Nombre: asda

Documento:

ID=4
Nombre=adas
Edad=asdas
Direccion=asdas

Tengo dudas si crear un documento con campos combinados o con marcas y lo
que no se es la instruccion par abrir el documento Word desde VB

Muchas gracias por adelantado

senzao18

  • Miembro HIPER activo
  • ****
  • Mensajes: 553
    • Ver Perfil
Re: Ayuda-necesito Crear Un Docemento Word Desde Vb
« Respuesta #1 en: Lunes 12 de Febrero de 2007, 17:41 »
0
Creo que la clase Process podria ayudarte

System.Diagnostics.Process

Código: Text
  1.  
  2.  En el siguiente ejemplo se utiliza una instancia de la clase Process para iniciar un proceso.
  3. [Visual Basic]
  4. Imports System
  5. Imports System.Diagnostics
  6. Imports System.ComponentModel
  7.  
  8.  
  9. Namespace MyProcessSample
  10.     _
  11.    '/ <summary>
  12.    '/ Shell for the sample.
  13.    '/ </summary>
  14.    Public Class MyProcess
  15.       ' These are the Win32 error code for file not found or access denied.
  16.       Private ERROR_FILE_NOT_FOUND As Integer = 2
  17.       Private ERROR_ACCESS_DENIED As Integer = 5
  18.      
  19.      
  20.       '/ <summary>
  21.       '/ Prints a file with a .doc extension.
  22.       '/ </summary>
  23.       Public Sub PrintDoc()
  24.          Dim myProcess As New Process()
  25.          
  26.          Try
  27.             ' Get the path that stores user documents.
  28.             Dim myDocumentsPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Personal)
  29.            
  30.             myProcess.StartInfo.FileName = myDocumentsPath + "\MyFile.doc"
  31.             myProcess.StartInfo.Verb = "Print"
  32.             myProcess.StartInfo.CreateNoWindow = True
  33.             myProcess.Start()
  34.          Catch e As Win32Exception
  35.             If e.NativeErrorCode = ERROR_FILE_NOT_FOUND Then
  36.                Console.WriteLine((e.Message + ". Check the path."))
  37.            
  38.             Else
  39.                If e.NativeErrorCode = ERROR_ACCESS_DENIED Then
  40.                   ' Note that if your word processor might generate exceptions
  41.                   ' such as this, which are handled first.
  42.                   Console.WriteLine((e.Message + ". You do not have permission to print this file."))
  43.                End If
  44.             End If
  45.          End Try
  46.       End Sub 'PrintDoc
  47.      
  48.      
  49.       Public Shared Sub Main()
  50.          Dim myProcess As New MyProcess()
  51.          myProcess.PrintDoc()
  52.       End Sub 'Main
  53.    End Class 'MyProcess
  54. End Namespace 'MyProcessSample
  55.  
  56.  
  57.  
  58.  
---------------------------------------
Erick Aragon Zepeda
Dessarrollo de Aplicaciones .NET
http]
Blog de Articulos
Mi Blog
NoSolocodigo -->