You are on page 1of 13

17/7/2014 Extraer Propiedades Word [Vba] - officefull (Word, Excel, Calc, Writer,...

)
http://www.officefull.es/programacion/35-extraer-propiedades-word-vba.html?tmpl=component&print=1&page= 1/13
Category: Visual Basic Aplicaciones Hits: 5924
Tweet 0 0 0
Extraer Propiedades Word [Vba]
Print

Extraer Propiedades Word
(VBA)

0 Like
17/7/2014 Extraer Propiedades Word [Vba] - officefull (Word, Excel, Calc, Writer,...)
http://www.officefull.es/programacion/35-extraer-propiedades-word-vba.html?tmpl=component&print=1&page= 2/13


Las propiedades de los documentos incluyen datos que nos informan detalladamente sobre el archivo en
17/7/2014 Extraer Propiedades Word [Vba] - officefull (Word, Excel, Calc, Writer,...)
http://www.officefull.es/programacion/35-extraer-propiedades-word-vba.html?tmpl=component&print=1&page= 3/13
cuestin. En Microsoft Word dichas propiedades pueden incluirse en Campos que son utilizados como
marcadores de posicin (Combinacin de correspondencia, Cartas, Etiquetas,...).
En este artculo os mostraremos una forma de extraer las propiedades de uno o varios documentos de
Word, mediante un procedimiento VBA, en el caso de que stas propiedades se necesiten almacenar en un
documento de Word.


Campos

Campos de Informacin de documento


17/7/2014 Extraer Propiedades Word [Vba] - officefull (Word, Excel, Calc, Writer,...)
http://www.officefull.es/programacion/35-extraer-propiedades-word-vba.html?tmpl=component&print=1&page= 4/13
17/7/2014 Extraer Propiedades Word [Vba] - officefull (Word, Excel, Calc, Writer,...)
http://www.officefull.es/programacion/35-extraer-propiedades-word-vba.html?tmpl=component&print=1&page= 5/13


Estas propiedades pueden ser utilizadas a lo largo de un documento de Word mediante
Campos, para insertar un Campo en Word podemos realizarlo bien desde el cuadro de
dilogo Campo o bien mediante la combinacin de teclas {CTRL+F9}, algunos de estos
campos tienen en comn algunas propiedades, como por ejemplo la propiedad AUTHOR:
{ DOCPROPERTY Author } { INFO Author } {Author}

Propiedades

Propiedades de Resumen para poder ser utilizados en Campos

Title - Subject - Author - Manager - Company - Category - Keywords - Comments
- HyperlinkBase


17/7/2014 Extraer Propiedades Word [Vba] - officefull (Word, Excel, Calc, Writer,...)
http://www.officefull.es/programacion/35-extraer-propiedades-word-vba.html?tmpl=component&print=1&page= 6/13
17/7/2014 Extraer Propiedades Word [Vba] - officefull (Word, Excel, Calc, Writer,...)
http://www.officefull.es/programacion/35-extraer-propiedades-word-vba.html?tmpl=component&print=1&page= 7/13


Propiedades de Estadsticas para poder ser utilizados en Campos

CreateDate - LastSavedTime - LastPrinted - LastSavedBy - RevNum - TotalEditingTime
- Pages - Paragraphs - Lines - Words - Characters - CharactersWithSpaces


17/7/2014 Extraer Propiedades Word [Vba] - officefull (Word, Excel, Calc, Writer,...)
http://www.officefull.es/programacion/35-extraer-propiedades-word-vba.html?tmpl=component&print=1&page= 8/13


Propiedades Personalizadas para poder ser utilizados en Campos
17/7/2014 Extraer Propiedades Word [Vba] - officefull (Word, Excel, Calc, Writer,...)
http://www.officefull.es/programacion/35-extraer-propiedades-word-vba.html?tmpl=component&print=1&page= 9/13

Las propiedades personalizadas pueden insertarse en el documento de Word como campos y
en el procedimiento VBA [ mtodo Item ], en el idioma de instalacin de Office, s stos
Existen, de lo contrario producir un error.


17/7/2014 Extraer Propiedades Word [Vba] - officefull (Word, Excel, Calc, Writer,...)
http://www.officefull.es/programacion/35-extraer-propiedades-word-vba.html?tmpl=component&print=1&page= 10/13


Procedimiento VBA
17/7/2014 Extraer Propiedades Word [Vba] - officefull (Word, Excel, Calc, Writer,...)
http://www.officefull.es/programacion/35-extraer-propiedades-word-vba.html?tmpl=component&print=1&page= 11/13

Campos que se deben de utilizar slo en el mtodo [ Item ]>>

Title= Ttulo
Subject= Asunto
Author= Autor
Keywords= Estos palabras clave
Comments= comentarios
Template= Normal.dotm
Last author= demo
Revision number= 131
Application name= Microsoft Office Word
Last print date= Jun/05/2009 6:08:00 PM
Creation date= May/28/2009 11:49:00 AM
Last save time= Jun/06/2009 10:12:59 AM
Total editing time= 522
Number of pages= 2
Number of words= 112
Number of characters= 652
Security= 0
Category= Categoria
Manager= Administrador
Company= Organizacin
Number of bytes= 33402
Number of lines= 4
Number of paragraphs= 34
Hyperlink base= 0
Number of characters (with spaces)= 742
Content status= Estado
El siguiente procedimiento como ejemplo, extrae en el documento las propiedades siguientes:

17/7/2014 Extraer Propiedades Word [Vba] - officefull (Word, Excel, Calc, Writer,...)
http://www.officefull.es/programacion/35-extraer-propiedades-word-vba.html?tmpl=component&print=1&page= 12/13
Fecha de creacin - Autor - Tiempo total empleado en la edicin del documento
- Fecha ltima en la que se guardo el documento.
Las propiedades son insertadas donde el cursor este situado en el documento de Word, NO esta preparado
para insertarlos en tablas ya que si quisiramos tener sus propiedades en una tabla, bastara con convertir el
texto en tabla desde la interfaz de Word:

Sub propiedades_documento()
Dim y As FileDialog, x As String, vrtSelectedItem, m As Object
Set y = Application.FileDialog(msoFileDialogFilePicker)
With y
.Title = "demo"<br />.AllowMultiSelect = <span style="color: #0000ff;">True<br />.Filters.Add
_<br />"Documentos de Word", "*.docm; *.doc; *.dot; *.docx; *.dotm; *.dotx"<br />
<span style="color: #0000ff;">If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
On Error GoTo suceso
Set m = Documents.Open(vrtSelectedItem, , , , , , , , , , , True)
With ActiveDocument.BuiltInDocumentProperties
x = .Item("Creation date") & " - " & .Item("Author") & _
" - " & .Item("Total editing time") & " - " & .Item("Last save time") & vbCrLf
m.Close savechanges:=wdDoNotSaveChanges
End With
ThisDocument.Activate: Selection.TypeText x: Next
Else
End If: End With
suceso:
If Err Then MsgBox ".. error :O ....?"
Set y = Nothing: Set m = Nothing: End Sub



Enlaces de inters

17/7/2014 Extraer Propiedades Word [Vba] - officefull (Word, Excel, Calc, Writer,...)
http://www.officefull.es/programacion/35-extraer-propiedades-word-vba.html?tmpl=component&print=1&page= 13/13
Acerca de los campos
http://office.microsoft.com/es-hn/word/HP051894753082.aspx
Establecer una base de hipervnculo
http://office.microsoft.com/es-es/word/HP051900413082.aspx



0
Share this on Google+ Share

Tweet 0

Web dedicada a la Informtica - Officefull.es 2007-2013 - webmaster[arroba]officefull.es
Sign Up to see what your f riends like. Like

You might also like