+ Reply to Thread
Results 1 to 12 of 12

Error when i give a name to a UserForm

Hybrid View

  1. #1
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Exclamation Error when i give a name to a UserForm

    Hi guys,
    i'am trying to creat a new UserForm with code and i would like to give it a name, here's the code, every time i receive the error code "75" error with the path...
    I have trid the two codes, and i have the same error for both of them:

    Sub MakeUserformFC()
        Dim TempForm As Object ' VBComponent
           Application.ScreenUpdating = False
        
    '   Create the UserForm
           Set TempForm = ActiveWorkbook.VBProject.VBComponents.Add(vbext_ct_MSForm)
        
        'Set Properties for TempForm
        With TempForm
            .Properties("Name") = "FonctionsContraintes"
            .Properties("Caption") = "Fonctions Contraintes"
            .Properties("Width") = 426.75
            .Properties("Height") = 318
        End With
    End Sub
    Sub MakeUserformFC()
        Dim TempForm As Object ' VBComponent
           Application.ScreenUpdating = False
        
    '   Create the UserForm
           Set TempForm = ActiveWorkbook.VBProject.VBComponents.Add(vbext_ct_MSForm)
        
        'Set Properties for TempForm
        With TempForm
            .Name = "FonctionsContraintes"
            .Properties("Caption") = "Fonctions Contraintes"
            .Properties("Width") = 426.75
            .Properties("Height") = 318
        End With
    End Sub
    Does anyone see where is the error???

    Thanks for your help.

  2. #2
    Forum Expert contaminated's Avatar
    Join Date
    05-07-2009
    Location
    Baku, Azerbaijan
    MS-Off Ver
    Excel 2013
    Posts
    1,430

    Re: Error when i give a name to a UserForm

    Try this....

    Set TempForm = ThisWorkbook.VBProject.VBComponents.Add(3)
    You cannot use the constant vbext_ct_MSForm without early binding.

    Source http://www.mrexcel.com/forum/showthread.php?t=51412
    Last edited by contaminated; 05-07-2010 at 04:48 AM.
    Люди, питающие благие намерения, как раз и становятся чудовищами.

    Regards, ?Born in USSR?
    Vusal M Dadashev

    Baku, Azerbaijan

  3. #3
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Error when i give a name to a UserForm

    The error that i have is in the line:
    .Properties("Name") = "FonctionsContraintes"
    or
    .Name = "FonctionsContraintes"
    The macro create the userform but doesn't succed to give it a name

  4. #4
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Error when i give a name to a UserForm

    Hi pierre08
       Dim objVBProj As VBProject ' add this line
        Dim TempForm As VBComponent ' change this line
    
     Set objVBProj = Application.VBE.ActiveVBProject ' add this line
        Set TempForm = objVBProj.VBComponents.Add(vbext_ct_MSForm)' change this line
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  5. #5
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Error when i give a name to a UserForm

    Doesn't work i have the same error

  6. #6
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Error when i give a name to a UserForm

    Now i have 2 errors the same number of error '75' but another description: specific object not found

  7. #7
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Error when i give a name to a UserForm

    It doesn't work i still have the same error in fact if crate the userform but when it attend the line of the name propriete it give me the error.
    Is there another way to name the userform or where is the error in the code.

  8. #8
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Error when i give a name to a UserForm

    dude
    try running this code as it works

     
        Dim objVBProj As VBProject
        Dim objVBComp As VBComponent
        Dim objVBFrm As UserForm
            
        Set objVBProj = Application.VBE.ActiveVBProject
        Set objVBComp = objVBProj.VBComponents.Add(vbext_ct_MSForm)
        
        With objVBComp
            .Name = "pTest"
            .Properties("Width") = 250
            .Properties("Height") = 250
            .Properties("Caption") = "Request Test"
        End With
    it should have created pTest userform

  9. #9
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Error when i give a name to a UserForm

    It works i don't know what changed i just restart my computer
    Thanks for your help guys

  10. #10
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Error when i give a name to a UserForm

    I have just one more question:
    is there a code that can verifie if the Name you're giving to a userform is use or not??

  11. #11
    Forum Contributor pierre08's Avatar
    Join Date
    02-16-2010
    Location
    Paris
    MS-Off Ver
    Excel 2003
    Posts
    166

    Re: Error when i give a name to a UserForm

    Found it:

     Sub UserFormTest()
    Dim objVBComp As VBComponent
           
        For Each objVBComp In ActiveWorkbook.VBProject.VBComponents
            If objVBComp.Type = vbext_ct_MSForm Then
                If  objVBComp.Name = "NameUserForm" Then
                    Exit Sub
                End If
            End If
        Next
      
    End Sub

  12. #12
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Error when i give a name to a UserForm

    well done

    I was playing with

        Dim objWin As VBIDE.Window
        Dim strOpenWindows As String
    
         For Each objWin In Application.VBE.Windows
                   strOpenWindows = strOpenWindows & _
                        objWin.Caption & vbCrLf
       Next
        MsgBox strOpenWindows
        Set objWin = Nothing

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1