Vba import file error - frm

Lauriedomini

New Member
Joined
Apr 19, 2017
Messages
1
Hello,

I've been running into errors in VBA in terms of inserting a frm. I get the error "Out of Memory." And the log says this: Line 8: Property OleObjectBlob in frmLogin had an invalid file reference. I've read through other posts in which this was resolved by changing the name of the frm to match the VBA code or removing extraneous "$" symbols in the VBA code. But this hasn't worked for me.

Can you tell me how I can fix my issue? Specifically this is what I'm doing...

Adding the below code to "ThisWorkbook":

Code:
Option Explicit
        Private Sub workbook_open()
        frmLogin.Show
         End Sub

Then right clicking on "ThisWorkbook" and inserting a frm that I saved to the desktop called "frmLogin.frm"

The code in the workbook.



Code:
VERSION 5.00
Begin {XXXXXXX} frmLogin 
   Caption         =   "XXXXXXXXX -  Secure Login"
   ClientHeight    =   2625
   ClientLeft      =   45
   ClientTop       =   375
   ClientWidth     =   5865
   OleObjectBlob   =   "frmLogin.frx":0000
   StartUpPosition =   1  'CenterOwner
End
Attribute VB_Name = "frmLogin"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False






Option Explicit


Private Sub cmdCancel_Click()
    frmLogin.Hide
    Unload frmLogin
    Exit Sub
End Sub


Private Sub cmdOk_Click()


    Dim wc As WorkbookConnection
    
    Dim oc As OLEDBConnection
    
    For Each wc In ActiveWorkbook.Connections
        If wc.Type = xlConnectionTypeOLEDB Then
            If wc.OLEDBConnection.OLAP Then
                If GetConnectionParameterValue(wc.OLEDBConnection.Connection, "User ID") <> frmLogin.txtUid Then
                    wc.OLEDBConnection.Connection = SetConnectionParameterValue(wc.OLEDBConnection.Connection, "User ID", frmLogin.txtUid)
                End If
                
                    wc.OLEDBConnection.Connection = SetConnectionParameterValue(wc.OLEDBConnection.Connection, "Password", frmLogin.txtPwd)
                    wc.OLEDBConnection.MakeConnection
                    wc.OLEDBConnection.SavePassword = False
            End If
        End If
    Next
    
    frmLogin.Hide
    Unload frmLogin
    
End Sub


Private Sub UserForm_Activate()
    Dim wc As WorkbookConnection
    
    Dim oc As OLEDBConnection
    
    For Each wc In ActiveWorkbook.Connections
        If wc.Type = xlConnectionTypeOLEDB Then
            If wc.OLEDBConnection.OLAP Then
                Me.txtUid = GetConnectionParameterValue(wc.OLEDBConnection.Connection, "User ID")
                Exit For
            End If
        End If
    Next
    frmLogin.txtPwd.SetFocus
    
End Sub


Private Function GetConnectionParameterValue(Connection As String, ParameterName As String) As String
    Dim StartPos As Integer
    Dim EndPos As Integer
    Dim ParameterValue As String
    Dim Parameter As String
    
    StartPos = InStr(1, Connection, ParameterName, vbTextCompare)
    If StartPos > 0 Then
        EndPos = InStr(StartPos, Connection, ";", vbTextCompare)
        If EndPos = 0 Then
            Parameter = Mid(Connection, StartPos)
        Else
            Parameter = Mid(Connection, StartPos, EndPos - StartPos)
        End If
    
        
        Dim ValueStartPos As Integer
        ValueStartPos = InStr(1, Parameter, "=")
        If ValueStartPos = 0 Then
            GetConnectionParameterValue = ""
        Else
            GetConnectionParameterValue = Mid(Parameter, ValueStartPos + 1, Len(Parameter) - ValueStartPos)
        End If
        
    End If
    
End Function


Private Function SetConnectionParameterValue(Connection As String, ParameterName As String, ParameterValue As String) As String
    Dim StartPos As Integer
    Dim EndPos As Integer
    Dim Parameter As String
    
    StartPos = InStr(1, Connection, ParameterName, vbTextCompare)
    If StartPos > 0 Then
        EndPos = InStr(StartPos, Connection, ";", vbTextCompare)
        If EndPos = 0 Then
            Parameter = Mid(Connection, StartPos)
        Else
            Parameter = Mid(Connection, StartPos, EndPos - StartPos)
        End If
    
        
        SetConnectionParameterValue = Replace(Connection, Parameter, ParameterName & "=" & ParameterValue, 1, -1, vbTextCompare)
    Else
        Dim Separator As String
        
        Connection = Trim(Connection)
        If Mid(Connection, Len(Connection), 1) = ";" Then
            Separator = ""
        Else
            Separator = ";"
        End If
        
        SetConnectionParameterValue = Connection & Separator & ParameterName & "=" & ParameterValue & ";"
    End If
    
End Function

Laurie
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Forum statistics

Threads
1,214,861
Messages
6,121,971
Members
449,059
Latest member
oculus

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top