我有一个错误
对象变量或未设置块变量
在Set lineProject = c.Row
使用以下代码时:
Private Sub CommandButton1_Click()
Dim pptFile As Object
Dim ppres As PowerPoint.Presentation
Path = "\\FSCFFACT\Activites\CFF DOMO GP ACT\Tableau de Bord\"
Set pptFile = CreateObject("Powerpoint.application")
If ComboBox1.Value <> "" Then
CODOMO.Hide
Libelle = ComboBox1.Value
lastline = Worksheets("Projets").Cells(Worksheets("Projets").Rows.Count, "B").End(xlUp).Row
Set c = Worksheets("Projets").Range("B10:B" & lastline).Find(Libelle)
Set lineProject = c.Row
pptFile.Presentations.Open (Path & "Modèle CODOMO.pptx")
Set pppres = pptFile.ActivePresentation
Else
...
End If
End Sub
我在另一个宏中使用了相同的行,使用Libelle查找项目的行。
谢谢你说出了什么问题。
我猜这是你得到错误的那一行
Set c = Worksheets("Projets").Range("B10:B" & lastline).Find(Libellé)
使用.Find(Libellé)
你的意思是Libellé
是字符串还是变量?
如果...
.Find("Libellé")
字符串.Find(Libelle)
将是正确的。
因为你的变量名是Libelle = ComboBox1.Value
确保使用Option Explicit
以避免输入错误的变量名称。并在使用前声明所有变量:
Dim Libelle As String
Libelle = ComboBox1.Value