MS-Project

Enlace a respuestas de otros usuarios

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Si tienes ms project y quieres hacer un Gantt, este codigo te sera algo util.

Private Sub Comando103_Click()

Call PrjTest

End Sub

Private Sub PrjTest()

Dim appPrjApp As MSProject.Application

Dim prjPrj As MSProject.Project

Dim db As Database

Dim rs As Recordset

Dim rsnombre As String

Dim l, D As Long

strsql = " Select Tbl_Proyectos.* FROM [" & lugarsecundario & "_Entidades.mdb" & "].Tbl_Proyectos "

strsql = strsql & " Where finalizada =0"

Set rs = CurrentDb.OpenRecordset(strsql)

If rs.RecordCount > 0 Then

l = 0

D = 0

Set appPrjApp = CreateObject("msproject.application")

appPrjApp.Visible = True

appPrjApp.FileNew

Set prjPrj = appPrjApp.Projects(1)

Do Until rs.BOF Or rs.EOF

rsnombre = rs!NombreProyecto

l = l + 1

D = D + 15

prjPrj.Tasks.Add rsnombre

prjPrj.Tasks(l).Duration = D & "d"

rs.MoveNext

Loop

End If

Set rs = Nothing

Set db = Nothing

End Sub

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

http://support.microsoft.com/kb/210014

La función de ejemplo proporcionada en este artículo abre un archivo existente de Microsoft Project y, a continuación, realiza las acciones siguientes:

  • Ejecuta una macro de Microsoft Project.
  • Agrega las tareas al proyecto.
  • Cambia las propiedades de fuente en una columna.
  • Se desplaza a una celda específica en el proyecto.
  • Muestra una vista preliminar impresión del proyecto.
  • Cierra el archivo de Microsoft Project y el programa.

Option Compare Database

Option Explicit

Function fncProjectOLE()

Dim prjApp As MSProject.Application

Dim prjProject As MSProject.Project

Dim intTask As Integer

Set prjApp = CreateObject("Msproject.Application")

prjApp.FileOpen "C:\Project1.mpp", ReadOnly:=True

prjApp.Visible = True

'Run a macro.

prjApp.Macro "Toggle_Read_Only" 'Toggle file back to read-write.

Set prjProject = prjApp.ActiveProject

'Add tasks to the project.

For intTask = 1 To 10

prjProject.Tasks.Add Name:="Task" & intTask

Next intTask

prjApp.SelectColumn

prjApp.FontItalic True 'Change font properties.

prjApp.EditGoTo 5, Date 'Go to a specific cell in the column.

prjApp.FilePrintPreview 'Print preview the file.

'prjApp.FilePrint 'Use this line to print the file.

'prjApp.FileSave 'Use this line to save the file.

prjApp.FileClose pjDoNotSave

prjApp.Quit

Set prjProject = Nothing

Set prjApp = Nothing

End Function

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

En Microsoft Excel, puede crear gráficos de Gantt que muestren el estado de tarea de proyecto Planeamiento y control.

En el ejemplo de este artículo muestra los pasos necesarios ...

Sub gantt_chart()

Dim rge As Variant

Dim mn As Variant

Dim shtname As Variant

'defines the variables

rge = Selection.Address()

'get the cell address

mn = Selection.Offset(1, 1)

'return the min value for the scale

Title = InputBox("Please enter the title")

'Asks the user for title

shtname = ActiveSheet.Name

'retains the name of current sheet

Application.ScreenUpdating=False

'Turns screen updating off

Charts.Add

'Create a paper model chart

ActiveChart.ChartWizard Source:=Sheets(shtname).Range(rge), _

Gallery:=xlBar, Format:=3, PlotBy:=xlColumns, CategoryLabels _

:=1, SeriesLabels:=1, HasLegend:=1, Title:=Title, _

CategoryTitle:="", ValueTitle:="", _

ExtraTitle:=""

' Basic chart definition

ActiveChart.Legend.Delete

'deletes the legend

ActiveChart.SeriesCollection(1).Select

'activates series 1

With Selection.Border

.Weight = xlThin

.LineStyle = xlNone

End With

'definition for the border for series 1

Selection.InvertIfNegative = False

'turns Invert if negative to false

Selection.Interior.ColorIndex = xlNone

'indicates that the area is set to none

ActiveChart.PlotArea.Select

'select the chart plot area

ActiveChart.Axes(xlCategory).Select

'select axis(1)

With ActiveChart.Axes(xlCategory)

.ReversePlotOrder = True

.TickLabelSpacing = 1

.TickMarkSpacing = 1

.AxisBetweenCategories = True

End With

'axis 1 definition

ActiveChart.Axes(xlValue).Select

'select axis(2)

With ActiveChart.Axes(xlValue)

.MinimumScale = mn

.MaximumScaleIsAuto = True

.MinorUnitIsAuto = True

.MajorUnitIsAuto = True

.Crosses = xlAutomatic

.ReversePlotOrder = False

.ScaleType = False

.HasMajorGridlines = True

.HasMinorGridlines = False

End With

' Axis(2) definition

End Sub

Ejemplo de cómo utilizar la macro

  1. Abra una hoja de cálculo nueva y escriba los siguientes valores:
        1. A1: B1: START C1: DAYS D1: DAYS
        2. A2: TASK B2: DATE C2: COMPLETED D2: REMAINING
        3. A3: TASK-1 B3: 1/1/91 C3: 150 D3: 15
        4. A4: TASK-2 B4: 5/1/91 C4: 21 D4: 31
        5. A5: TASK-3 B5: 7/1/91 C5: 0 D5: 114
        6. A6: TASK-4 B6: 10/1/91 C6: 0 D6: 4
        7. A7: TASK-5 B7: 10/15/91 C7: 0 D7: 31
        8. A8: TASK-6 B8: 11/1/91 C8: 0 D8: 2