Project) (Application 物件
代表整個 Project 應用程式。 Application 物件包含:
應用程式範圍的設定與選項 (例如,在 [工具] 功能表的 [選項] 對話方塊中的許多選項)。
用來傳回最高層級物件數目的屬性,例如 ActiveCell 屬性及 ActiveProject 屬性等。
作用於應用程式範圍之元素的方法,例如,檢視、選取及編輯動作等。
使用 Application 物件
使用 Application 屬性來傳回專案中的 應用程式 的物件。 下列範例將 Windows 屬性套用至應用程式物件。
Application.Windows("Project1.mpp").Activate
從另一個應用程式使用專案:晚期繫結
下列範例會建立 Microsoft Project 應用程式 物件在執行階段、 建立新的專案、 新增任務、 儲存專案,然後關閉專案。 例如,複製並貼入 ThisDocument模組 CreateProject_Late巨集在 Visual Basic 編輯器 (VBE) 的Word。
注意事項
[!注意事項] 因為應用程式只會在執行階段查詢 MSProject.Application 型別程式庫、 Microsoft IntelliSense 不提供與效能低落較與晚期繫結。 指令碼語言,例如JavaScript和 VBScript 中,需要晚期繫結。 VBScript 中支援僅將泛用 物件 及 Variant 資料類型。 VBA 和其他編譯的語言的較佳效能,您應該使用早期繫結藉由設定專案型別程式庫的參照。
Sub CreateProject_Late()
Dim pjApp As Object
Set pjApp = CreateObject("MSProject.Application")
pjApp.Visible = True
pjApp.FileNew
pjApp.ActiveProject.Tasks.Add "Hang clocks"
pjApp.FileSaveAs "Clocks.mpp"
pjApp.FileClose
pjApp.Quit
End Sub
如果您未將 Visible 屬性設定為 True,Project 應用程式會在背景中運作,而不會顯示。
從另一個應用程式使用專案:早期繫結
因為它在設計階段載入型別程式庫早期繫結會有較佳的效能。 若要使用早期繫結,您必須設定中所使用的應用程式的 Project 應用程式的參照。 例如,就會在 VBE Word文件,在 [ 工具] 功能表上的 [ 參考、 捲動 可用的參考] 清單中,然後選擇 [ Microsoft Project 15.0 物件程式庫] 核取方塊。
下面範例從另一個應用程式例如Excel開啟專案、 工作、 新增,然後儲存並關閉專案。
Sub ModifyProject_Early()
Dim pjApp As MSProject.Application
Set pjApp = New MSProject.Application
pjApp.Visible = True
pjApp.FileOpen "Clocks.mpp"
pjApp.ActiveProject.Tasks.Add "Wind clocks"
pjApp.FileSave
pjApp.FileClose
pjApp.Quit
End Sub
註解
重要事項
針對應用層級事件,請在設定 Application.Visible = True
之後註冊事件處理常式。
如果您從另一個應用程式產生專案並登錄應用程式層級事件之後,將 [應用程式] 物件的 [可見] 屬性設為 [True],則應用程式子物件的屬性和方法會無法運作。 例如,Application.ActiveProject.Name
無法存取。
屬性和方法會傳回最常見的使用者介面物件,例如使用中專案的許多 由 ActiveProject 屬性代表 可以使用無 應用程式 物件辨識符號。 例如,而不是撰寫 Application.ActiveProject.Visible = True
您可以撰寫 ActiveProject.Visible = True
事件
- AfterCubeBuilt
- ApplicationBeforeClose
- ConnectionStatusChanged
- IsFunctionalitySupported
- JobCompleted
- JobStart
- LoadWebPage
- LoadWebPane
- NewProject
- OnUndoOrRedo
- PaneActivate
- ProjectAfterSave
- ProjectAssignmentNew
- ProjectBeforeAssignmentChange
- ProjectBeforeAssignmentChange2
- ProjectBeforeAssignmentDelete
- ProjectBeforeAssignmentDelete2
- ProjectBeforeAssignmentNew
- ProjectBeforeAssignmentNew2
- ProjectBeforeClearBaseline
- ProjectBeforeClose
- ProjectBeforeClose2
- ProjectBeforePrint
- ProjectBeforePrint2
- ProjectBeforePublish
- ProjectBeforeResourceChange
- ProjectBeforeResourceChange2
- ProjectBeforeResourceDelete
- ProjectBeforeResourceDelete2
- ProjectBeforeResourceNew
- ProjectBeforeResourceNew2
- ProjectBeforeSave
- ProjectBeforeSave2
- ProjectBeforeSaveBaseline
- ProjectBeforeTaskChange
- ProjectBeforeTaskChange2
- ProjectBeforeTaskDelete
- ProjectBeforeTaskDelete2
- ProjectBeforeTaskNew
- ProjectBeforeTaskNew2
- ProjectCalculate
- ProjectResourceNew
- ProjectTaskNew
- SaveCompletedToServer
- SaveStartingToServer
- SecondaryViewChange
- WindowActivate
- WindowBeforeViewChange
- WindowDeactivate
- WindowGoalAreaChange
- WindowSelectionChange
- WindowSidepaneDisplayChange
- WindowSidepaneTaskChange
- WindowViewChange
- WorkpaneDisplayChange
方法
名稱 |
---|
- About
- ActivateMicrosoftApp
- AddNewColumn
- AddProgressLine
- AddResourcesFromProjectServer
- AddSiteColumn
- AfterUnloadWebBrowserControl
- 提醒
- AlignTableCellBottom
- AlignTableCellTop
- AlignTableCellVerticalCenter
- AppExecute
- ApplyReport
- ApplyReportLayoutTemplate
- AppMaximize
- AppMinimize
- AppMove
- AppRestore
- AppSize
- AutoCorrect
- AutoFilter
- AutoSaveToGlobal
- BarBoxFormat
- BarBoxStyles
- BarRounding
- BaseCalendarCreate
- BaseCalendarDelete
- BaseCalendarEditDays
- BaseCalendarRename
- BaseCalendarReset
- BaseCalendars
- BaselineClear
- BaselineSave
- BoxAlign
- BoxCellEdit
- BoxCellEditEx
- BoxCellLayout
- BoxDataTemplate
- BoxFormat
- BoxFormatEx
- BoxGetXPosition
- BoxGetYPosition
- BoxLayout
- BoxLayoutEx
- BoxLinkLabelsShow
- BoxLinks
- BoxLinksEx
- BoxLinkStyleToggle
- BoxProgressMarksShow
- BoxSet
- BoxShowHideFields
- BoxStylesEdit
- BoxStylesEditEx
- BoxZoom
- CacheSettings
- CacheStatus
- CalculateAll
- CalculateProject
- CalendarBarStyles
- CalendarBarStylesEdit
- CalendarBarStylesEditEx
- CalendarBestFitWeekHeight
- CalendarDateBoxes
- CalendarDateBoxesEx
- CalendarDateShading
- CalendarDateShadingEdit
- CalendarDateShadingEditEx
- CalendarLayout
- CalendarShowBarSplits
- CalendarTaskList
- CalendarTimescale
- CalendarWeekHeadingsEx
- ChangeColumnDataType
- ChangeStatusDate
- ChangeWorkingTimeEx
- CheckField
- CheckIn
- CheckOut
- CheckResourceErrors
- CheckTaskErrors
- CleanupCache
- CleanupProjectFromCache
- ClearConstraint
- CloseComparison
- CloseUndoTransaction
- ColumnAlignment
- ColumnBestFit
- ColumnDelete
- ColumnEdit
- ColumnInsert
- ComAddInsDialog
- CommitmentsPane
- CompareProjectsLegendToggle
- CompareProjectVersions
- ConsolidateProjects
- ConvertHangulToHanja
- CopyReport
- CreateComparisonReport
- CreateEnterpriseCalendar
- CreateProjectSite
- CustomFieldDelete
- CustomFieldGetFormula
- CustomFieldGetName
- CustomFieldIndicatorAdd
- CustomFieldIndicatorDelete
- CustomFieldIndicators
- CustomFieldMappingDialog
- CustomFieldPropertiesEx
- CustomFieldRename
- CustomFieldSetFormula
- CustomFieldValueList
- CustomFieldValueListAdd
- CustomFieldValueListDelete
- CustomFieldValueListGetItem
- CustomForms
- CustomizeField
- CustomizeIMEMode
- CustomOutlineCodeEditEx
- DateAdd
- DateDifference
- DateFormat
- DateSubtract
- DDEExecute
- DDEInitiate
- DDELinksUpdate
- DDEPasteLink
- DDETerminate
- DeleteFromDatabase
- DependenciesPane
- DetailsPaneToggle
- DetailStylesAdd
- DetailStylesFormat
- DetailStylesFormatEx
- DetailStylesProperties
- DetailStylesRemove
- DetailStylesRemoveAll
- DetailStylesToggleItem
- DisplaySharedWorkspace
- DistributeTableColumns
- DistributeTableRows
- DocClose
- DocMaximize
- DocMove
- DocRestore
- DocSize
- DocumentExport
- DocumentLibraryVersionsDialog
- DrawingCreate
- DrawingCycleColor
- DrawingMove
- DrawingProperties
- DrawingReshape
- DurationFormat
- DurationValue
- EditClear
- EditClearFormats
- EditClearHyperlink
- EditCopy
- EditCopyPicture
- EditCut
- EditDelete
- EditEnterpriseCalendar
- EditGoTo
- EditHyperlink
- EditInsert
- EditPaste
- EditPasteAsHyperlink
- EditPasteSpecial
- EditRedo
- EditTPStyle
- EditUndo
- EnterpriseGlobalCheckOut
- EnterpriseMakeServerURLTrusted
- EnterpriseProjectDelete
- EnterpriseProjectImportWizard
- EnterpriseProjectProfiles
- EnterpriseResourceGet
- EnterpriseResourcesImportEx
- EnterpriseResourcesOpen
- EnterpriseResSubstitutionWizard
- EnterpriseTeamBuilder
- FieldConstantToFieldName
- FieldNameToFieldConstant
- FileCloseAllEx
- FileCloseEx
- FileExit
- FileLoadLast
- FileNew
- FileOpenEx
- FileOpenOrCreate
- FileOpenUsingBackstage
- FilePageSetup
- FilePageSetupCalendar
- FilePageSetupCalendarText
- FilePageSetupCalendarTextEx
- FilePageSetupFooter
- FilePageSetupHeader
- FilePageSetupLegend
- FilePageSetupLegendEx
- FilePageSetupMargins
- FilePageSetupPage
- FilePageSetupView
- FilePrint
- FilePrintPreview
- FilePrintSetup
- FileProperties
- FileSave
- FileSaveAs
- FileSaveOffline
- FileSaveWorkspace
- FillAcross
- FillDown
- FilterApply
- FilterClear
- FilterEdit
- FilterNew
- 篩選器
- FilterShowSummaryRows
- Find
- FindEx
- FindFile
- FindNext
- FindPrevious
- FollowHyperlink
- Font32Ex
- FontBold
- FontEx
- FontItalic
- FontStrikethrough
- FontUnderLine
- 表單
- FormatCopy
- FormatPainter
- FormatPaste
- FormViewShow
- GanttBarEditEx
- GanttBarFormat
- GanttBarFormatEx
- GanttBarLinks
- GanttBarSize
- GanttBarStyleBaseline
- GanttBarStyleCritical
- GanttBarStyleDelete
- GanttBarStyleEdit
- GanttBarStyleLate
- GanttBarStyleSlack
- GanttBarStyleSlippage
- GanttBarTextDateFormat
- GanttChartWizard
- GanttRollup
- GanttShowBarSplits
- GanttShowDrawings
- GetCellInfo
- GetCurrentTheme
- GetProjectServerSettingsEx
- GetProjectServerVersion
- GetRedoListCount
- GetRedoListItem
- GetThemedColor
- GetUndoListCount
- GetUndoListItem
- GoalAreaChange
- GoalAreaHighlight
- GoalAreaTaskHighlight
- GoToItemInVersions
- GotoNextOverAllocation
- GotoTaskDates
- 格線
- GridlinesEdit
- GridlinesEditEx
- GroupApply
- GroupBy
- GroupClear
- GroupMaintainHierarchy
- GroupNew
- 群組
- HelpAbout
- HelpAnswerWizard
- HelpContents
- HelpLaunch
- HelpTechnicalSupport
- HighlightDrivenSuccessors
- HighlightDrivingPredecessors
- HighlightPredecessors
- HighlightSuccessors
- ImportCommitment
- ImportOutlookTasks
- InactivateTaskToggle
- InformationDialog
- InsertBlankRow
- InsertHyperlink
- InsertManualTask
- InsertMilestoneTask
- InsertNotes
- InsertResource
- InsertScheduledTask
- InsertSummaryTask
- InsertTask
- IsCommandEnabled
- IsOfficeTaskPaneVisible
- IsOffline
- IsReducedFunctionalityMode
- IsUndoingOrRedoing
- IsURLTrusted
- Layout
- LayoutNow
- LayoutRelatedNow
- LayoutSelectionNow
- LevelingClear
- LevelingOptions
- LevelingOptionsEx
- LevelNow
- LevelSelected
- LinksBetweenProjects
- LinkTasks
- LinkTasksEdit
- LinkToTaskList
- LoadWebBrowserControlEx
- LoadWebPaneControl
- LocaleID
- LookUpTableAddEx
- 巨集
- MacroSecurity
- MacroShowCode
- MacroShowVba
- MailLogoff
- MailLogon
- MailPostDocument
- MailRoutingSlip
- MailSend
- MailSession
- MailSystem
- MakeFieldEnterprise
- MakeLocalCalendarEnterprise
- ManageSiteColumns
- MapEdit
- 訊息
- NewTasksStartOn
- ObjectChangeIcon
- ObjectConvert
- ObjectInsert
- ObjectLinks
- ObjectVerb
- OfficeOnTheWeb
- OfficeTaskPaneHide
- OpenBrowser
- OpenFromSharePoint
- OpenServerPage
- OpenUndoTransaction
- OpenXML
- OptionsCalculation
- OptionsCalendar
- OptionsEditEx
- OptionsGeneralEx
- OptionsInterfaceEx
- OptionsSave
- OptionsSchedule
- OptionsSecurityEx
- OptionsSecurityTab
- OptionsSpelling
- OptionsViewEx
- 召集人
- OrganizerDeleteItem
- OrganizerMoveItem
- OrganizerRenameItem
- OutlineHideSubTasks
- OutlineIndent
- OutlineOutdent
- OutlineShowAllTasks
- OutlineShowSubTasks
- OutlineShowTasks
- OutlineSymbolsToggle
- PageBreakRemove
- PageBreakSet
- PageBreaksRemoveAll
- PageBreaksShow
- PaneClose
- PaneCreate
- PaneNext
- PanZoomPanTo
- PanZoomZoomTo
- PasteAsPicture
- PasteDestFormatting
- PasteSourceFormatting
- ProgressLines
- ProjectCheckOut
- ProjectMove
- ProjectStatistics
- ProjectSummaryInfo
- 發佈
- Quit
- ReassignSelectedAssns
- RecurringTaskInsert
- Redo
- RegisterProject
- ReminderSet
- RemoveHighlight
- RenameReport
- Replace
- ReplaceEx
- ReportPrint
- ReportPrintPreview
- 報告
- ReportsDialog
- RequestProgressInformation
- RescheduleToNextAvailable
- ResetTPStyle
- ResourceActiveDirectory
- ResourceAddressBook
- ResourceAssignment
- ResourceAssignmentDialog
- ResourceCalendarEditDays
- ResourceCalendarReset
- ResourceCalendars
- ResourceComparison
- ResourceDetails
- ResourceGraphBarStyles
- ResourceGraphBarStylesEx
- ResourceMappingDialog
- ResourceSharing
- ResourceSharingPoolAction
- ResourceSharingPoolRefresh
- ResourceSharingPoolUpdate
- ResourceWindowsAccount
- RestoreSheetSelection
- RowClear
- RowDelete
- RowInsert
- Run
- SaveForSharing
- SaveSheetSelection
- SegmentBorderColor
- SegmentFillColor
- SelectAll
- SelectBeginning
- SelectCell
- SelectCellDown
- SelectCellLeft
- SelectCellRight
- SelectCellUp
- SelectColumn
- SelectEnd
- SelectionExtend
- SelectRange
- SelectResourceCell
- SelectResourceColumn
- SelectResourceField
- SelectRow
- SelectRowEnd
- SelectRowStart
- SelectSheet
- SelectTable
- SelectTaskAssns
- SelectTaskCell
- SelectTaskColumn
- SelectTaskField
- SelectTimescaleRange
- SelectToEnd
- SelectTPLineHeight
- SelectTPTask
- ServiceOptionsDialog
- SetActiveCell
- SetAutoFilter
- SetField
- SetLTRTable
- SetMatchingField
- SetResourceField
- SetResourceFieldByID
- SetRowHeight
- SetRTLTable
- SetShowTaskSuggestions
- SetShowTaskWarnings
- SetSidepaneStateButton
- SetSplitBar
- SetTaskField
- SetTaskFieldByID
- SetTaskMode
- SetTitleRowHeight
- SetTPField
- ShareProjectOnline
- ShowAddNewColumn
- ShowIgnoredTaskWarnings
- ShowOSFTaskPane
- ShowReportDataPane
- SidepaneTaskChange
- SidepaneToggle
- Sort
- SpellCheckField
- SpellingCheck
- SplitTask
- StopWebBrowserControlNavigation
- SummaryResourceAssignmentsRefresh
- SummaryTasksShow
- SynchronizeWithSite
- 表格
- TableApply
- TableCopy
- TableEdit
- TableEditEx
- TableReset
- Tables
- TaskComparison
- TaskDeliverableCreate
- TaskDeliverableSync
- TaskDependencySync
- TaskDrivers
- TaskInspector
- TaskMove
- TaskMoveToStatusDate
- TaskOnTimeline
- TaskRespectLinks
- TextStyles32Ex
- TextStylesEx
- TimelineExport
- TimelineFormat
- TimelineGotoSelectedTask
- TimelineInsertTask
- TimelineShowHide
- TimelineTextOnBar
- TimelineViewToggle
- 時幅
- TimescaleEdit
- TimescaleNonWorking
- TimescaleNonWorkingEx
- ToggleAssignments
- ToggleChangeHighlighting
- TogglePreventResOveralloc
- ToggleResourceDetails
- ToggleTaskDetails
- ToggleTPAutoExpand
- ToggleTPResourceExpand
- ToggleTPUnassigned
- ToggleTPUnscheduled
- Undo
- UndoClear
- UnlinkTasks
- UnloadWebBrowserControl
- UpdateFromProjectServer
- UpdateProject
- UpdateTasks
- UsageViewEntryEx
- ViewApply
- ViewApplyEx
- ViewBar
- ViewCopy
- ViewEditCombination
- ViewEditSingle
- ViewReset
- 檢視
- ViewsEx
- ViewShowCost
- ViewShowCumulativeCost
- ViewShowCumulativeWork
- ViewShowNotes
- ViewShowObjects
- ViewShowOverallocation
- ViewShowPeakUnits
- ViewShowPercentAllocation
- ViewShowPredecessorsSuccessors
- ViewShowRemainingAvailability
- ViewShowResourcesPredecessors
- ViewShowResourcesSuccessors
- ViewShowSchedule
- ViewShowUnitAvailability
- ViewShowWork
- ViewShowWorkAvailability
- VisualReports
- VisualReportsEdit
- VisualReportsNewTemplate
- VisualReportsSaveCube
- VisualReportsSaveDatabase
- VisualReportsView
- WBSCodeMaskEdit
- WBSCodeRenumber
- WebAddToFavorites
- WebCopyHyperlink
- WebGoBack
- WebGoForward
- WebHideToolbars
- WebOpenFavorites
- WebOpenHyperlink
- WebOpenSearchPage
- WebOpenStartPage
- WebRefresh
- WebSetSearchPage
- WebSetStartPage
- WebStopLoading
- WebToolbar
- WindowActivate
- WindowArrangeAll
- WindowHide
- WindowMoreWindows
- WindowNewWindow
- WindowNext
- WindowPrev
- WindowSplit
- WindowUnhide
- WorkOffline
- WrapText
- Zoom
- ZoomCalendar
- ZoomIn
- ZoomOut
- ZoomReport
- ZoomTimescale
- AddEngagement
- EngagementInfo
- GetDpiScaleFactor
- InsertTimelineBar
- 檢查
- LocaleName
- ProjectSummaryInfoEx
- RefreshEngagementsForProject
- RemoveTimelineBar
- SubmitAllEngagementsForProject
- SubmitSelectedEngagementsForProject
- TaskOnTimelineEx
- TimelineBarDateRange
- UpdateEngagementsForProject
屬性
名稱 |
---|
- ActiveCell
- ActiveProject
- ActiveSelection
- ActiveWindow
- AMText
- 應用程式
- AskToUpdateLinks
- Assistance
- AutoClearLeveling
- AutoLevel
- AutomaticallyFillPhoneticFields
- AutomationSecurity
- 組建
- Calculation
- Caption
- CellDragAndDrop
- COMAddIns
- CommandBars
- CompareProjectsCurrentVersionName
- CompareProjectsPreviousVersionName
- DateOrder
- DateSeparator
- DayLeadingZero
- DecimalSeparator
- DefaultAutoFilter
- DefaultDateFormat
- DefaultView
- DisplayAlerts
- DisplayEntryBar
- DisplayOLEIndicator
- DisplayPlanningWizard
- DisplayProjectGuide
- DisplayRecentFiles
- DisplayScheduleMessages
- DisplayScrollBars
- DisplayStatusBar
- DisplayViewBar
- DisplayWindowsInTaskbar
- DisplayWizardErrors
- DisplayWizardScheduling
- DisplayWizardUsage
- 版本
- EnableCancelKey
- EnableChangeHighlighting
- EnterpriseAllowLocalBaseCalendars
- EnterpriseListSeparator
- EnterpriseProtectActuals
- FileBuildID
- FileFormatID
- GetCacheStatusForProject
- GlobalBaseCalendars
- GlobalOutlineCodes
- GlobalReports
- GlobalResourceFilters
- GlobalResourceTables
- GlobalTaskFilters
- GlobalTaskTables
- GlobalViews
- GlobalViewsCombination
- GlobalViewsSingle
- Height
- IsCheckedOut
- Left
- LevelFreeformTasks
- LevelIndividualAssignments
- LevelingCanSplit
- LevelOrder
- LevelPeriodBasis
- LevelProposedBookings
- LevelWithinSlack
- ListSeparator
- LoadLastFile
- MonthLeadingZero
- MoveAfterReturn
- 名稱
- NewTasksEstimated
- OperatingSystem
- PanZoomFinish
- PanZoomStart
- Parent
- Path
- PathSeparator
- PMText
- 設定檔
- 專案
- PromptForSummaryInfo
- RecentFilesMaximum
- ScreenUpdating
- ShowAssignmentUnitsAs
- ShowEstimatedDuration
- ShowWelcome
- StartWeekOn
- StartYearIn
- StatusBar
- SupportsMultipleDocuments
- SupportsMultipleWindows
- ThousandSeparator
- TimeLeadingZero
- TimescaleFinish
- TimescaleStart
- TimeSeparator
- Top
- TrustProjectServerAndWSSPages
- TwelveHourTimeFormat
- UndoLevels
- UsableHeight
- UsableWidth
- Use3DLook
- UseOMIDs
- UserControl
- UserName
- VBE
- Version
- Visible
- VisualReportsAdditionalTemplatePath
- VisualReportTemplateList
- Width
- Windows
- Windows2
- WindowState
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。