gpt4 book ai didi

vba - MS项目: how to check in VBA if a column is visible in tasks view?

转载 作者:行者123 更新时间:2023-12-02 03:33:55 24 4
gpt4 key购买 nike

我在MSP中编写了一个VBA宏来插入一列(TaskColumn Flag20)来显示特定指标。它工作得很好,只是每次我打开项目文件时它都会创建列。因此,我正在寻找一种方法来检查该列是否存在并且在打开文件时是否可见。我找不到任何有关这种可能性的信息。

非常感谢。

最佳答案

这是一种以编程方式获取所有可见列的方法

'The function returns all of the visible column names as a delimiter separated string.
' Call with a string as the first parameter to represent a custom delimiter, or leave
' blank to use the default of a comma ,
Function GetColumns(Optional customDelimeter As String) As String
If customDelimeter = "" Then customDelimeter = "," 'handle custom delimeter

Dim viewableColumns As String 'create return value

SelectRow Row:=1, RowRelative:=False 'select the 1st row then parse all columns composing that row
For Each lngFieldID In MSProject.ActiveSelection.FieldIDList
Dim columnName As String
If lngFieldID > 0 Then

'convert the column ID to a string of the field name, either custom or built-in
columnName = Trim((CustomFieldGetName(lngFieldID)))
If Len(columnName) = 0 Then
columnName = Trim(FieldConstantToFieldName(lngFieldID)) ' use the built-in field name
End If

'append return value
viewableColumns = viewableColumns & customDelimeter & columnName
End If
Next

'get rid of the first delimeter
If Len(viewableColumns) > 0 Then
viewableColumns = Right(viewableColumns, Len(viewableColumns) - 1)
End If

GetColumns = viewableColumns

End Function

关于vba - MS项目: how to check in VBA if a column is visible in tasks view?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50967863/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com