Fejl - komponenten kan ikke oprette objektet?
Hej VB eksperter,Dette VBScript starter Adobe Photoshop, men jeg får følgende fejl umiddelbart derefter (jeg starter VBscriptet fra min Windows XP desktop hvorefter den åbner Photoshop).:
Linie: 12
Tegn: 1
Fejl: ActivX-komponenten kan ikke oprettet objektet: 'Photoshop.Document'
Kode: 800A01AD
Kilde: Der opstod en Microsoft VBScript-kørselsfejl
Sådan her ser koden ud. Nogen ide om hvad der kan være galt?
Sub DoResize()
'-- Mr. Ali: I created this code with Visual Basic V6
' 2006-02-24 Tilrettet
'Dim appRef As Photoshop.Application
DIM appRef
SET appRef = CreateObject("Photoshop.Application")
'Dim docRef2 As Photoshop.Document
DIM docRef2
SET docRef2 = CreateObject("Photoshop.Document")
Dim long_side
Dim short_side
Dim dpi
Dim nW
Dim nH
Dim proportion1
Dim proportion2
Dim newX
Dim newY
'dim fileName as string
DIM fileName
SET fileName = String
long_side = 583 ' Must be > 0
short_side = 0 ' You must leave this to 0 if you decide to assign a value to long_side variable.
dpi = 300 ' 72
Set appRef = CreateObject("Photoshop.Application")
' Set the ruler units.
'Dim strtRulerUnits As Photoshop.PsUnits
DIM strtRulerUnits
SET strtRulerUnits = "Photoshop.PsUnits"
' Set Photoshop dialogs option to not be displayed during automated execution
appRef.DisplayDialogs = psDisplayNoDialogs
' Set current ruler units in Preferences is pixels
strtRulerUnits = appRef.Preferences.RulerUnits
appRef.Preferences.RulerUnits = psPixels
'fileName = appRef.Path & "\Samples\Ranch House.jpg"
fileName = "C:\\temp\\AutoCrop_Eksperiment\\IMG_1819.jpg"
Set docRef2 = appRef.Open(fileName)
If appRef.Documents.Count > 0 Then
Set docRef2 = appRef.ActiveDocument
' Initialise the fixed variables
Set docRef2 = appRef.ActiveDocument
nW = docRef2.Width
nH = docRef2.Height
If long_side = 0 Then
'fit to short side
If (nW > nH) Then
proportion1 = short_side / nH
Else
proportion1 = short_side / nW
End If
ElseIf short_side = 0 Then
' fit to long side
If (nW > nH) Then
proportion1 = long_side / nW
Else
proportion1 = long_side / nH
End If
End If
If (nW > nH) Then
proportion1 = long_side / nW
proportion2 = short_side / nH
Else
proportion1 = short_side / nW
proportion2 = long_side / nH
End If
If (proportion1 >= proportion2) Then
newX = proportion1 * nW
newY = proportion1 * nH
Else
newX = proportion2 * nW
newY = proportion2 * nH
End If
If (newX > nW) Then
docRef2.ResizeImage newX, newY, dpi, bicubic
Else
docRef2.ResizeImage newX, newY, dpi, bicubic
End If
Else
MsgBox ("no image is active")
End If
End Sub
' Kald routinen
doResize()