我试图改变一个层的颜色使用vba
基本上,我有一个纹理文件,我想改变它的基础上的细胞值层,因为我需要创建大量的。电子表格上的颜色值为R G B格式。
我有两个版本的PSD文件(可以修改),一个颜色叠加,另一个只是作为一个调整层Fillcolor。
尝试了以下操作,并尝试在对象中查找颜色属性,但找不到>
有什么建议吗?
Sub modify_psd_files()
'Define variables for Excel and Photoshop objects
Dim appExcel As Excel.Application
Dim wbExcel As Excel.Workbook
Dim wsExcel As Excel.Worksheet
Dim appPhotoshop As Object 'Declare as Object to use late binding
Dim docPhotoshop As Object 'Declare as Object to use late binding
'Define variables for the file names and paths
Dim filePath As String
Dim fileName As String
Dim savePath As String
Dim saveName As String
'Define variables for the layer name and color
Dim layerName As String
Dim layerColor As String
Dim hexColor As String
Dim r As Integer
Dim g As Integer
Dim b As Integer
'Open Excel file and set variables
Set appExcel = New Excel.Application
Set wbExcel = ThisWorkbook 'Use the workbook executing the code
Set wsExcel = wbExcel.Worksheets("PSD")
'Open Photoshop and set variables
Set appPhotoshop = CreateObject("Photoshop.Application")
appPhotoshop.Visible = True 'Set to False to hide Photoshop
'Loop through rows in Excel and modify Photoshop file
For i = 2 To wsExcel.Cells(wsExcel.Rows.Count, "A").End(xlUp).Row
'Get file name, layer name, layer color, and save name from Excel
fileName = ThisWorkbook.Path & "\" & wsExcel.Cells(i, 1).Value 'Use workbook path as base path for file
layerName = wsExcel.Cells(i, 2).Value
hexColor = wsExcel.Cells(i, 3).Value
saveName = wsExcel.Cells(i, 4).Value
'Open PSD file and set variables
Set docPhotoshop = appPhotoshop.Open(fileName)
Dim layer As Object 'Declare as Object to use late binding
'Find layer by name and change color
For Each layer In docPhotoshop.artLayers
If layer.Name = layerName Then
Dim artLayer As Object 'Declare as Object to use late binding
Set artLayer = layer
artLayer.ApplyColorOverlay
artLayer.adjustment.ColorBalance(0) = 100
artLayer.adjustment.ColorBalance(1) = 100
artLayer.adjustment.ColorBalance(2) = 100
Exit For
End If
Next layer
'Save modified file with new name
savePath = Left(fileName, InStrRev(fileName, "\")) 'Get path from original file name
docPhotoshop.SaveAs savePath & saveName & ".tga"
docPhotoshop.Close
Next i
'Close Excel and Photoshop and clean up objects
'wbExcel.Close
'appExcel.Quit
'appPhotoshop.Quit
'Set wsExcel = Nothing
'Set wbExcel = Nothing
'Set appExcel = Nothing
End Sub
1条答案
按热度按时间ukdjmx9f1#
我提供以下的解决方案给你和任何人与Photoshop和DOM。
使用WordPress的知识在Photoshop中打开所需的PSD文件,搜索solidfill层并激活它。(这你必须自己做)en使用下面的解决方案
chgcol()
来改变固体填充层的颜色。在下面的解决方案中,photoshop JavaScript
.jsx
文件是从xml2调用的。技巧是设置环境变量,我很欣赏这个link1.创建一个文本文件并给予名称
changecolorfill.jsx
1.将以下代码放入其中并保存
1.在photoshop中打开文件,其中将有一个填充颜色层,并使该层可见和活动。
1.在JavaScript模块中,放入以下代码并运行chgcol()子例程。#3f79bd是皇家蓝色十六进制码。
.
谢谢...