Home > Software engineering >  Program "object variables or With variable block is not set" error, ask ace to help have a
Program "object variables or With variable block is not set" error, ask ace to help have a

Time:10-09

Public VBInstance As VBIde. VBE varies
Public Connect As Connect
Dim strDefPath As String
Option Explicit



Private Sub CancelButton_Click ()
Unload Me
Connect. Hide
End Sub

Private Sub Form_Load ()
Dim objComponent As VBComponent
Dim objMember As Member
Dim strTemp As String
Dim intTemp As Integer
Dim strCurrExports ()

ReDim strCurrExports (0)

. 'to find the path for the def file of the current project
StrDefPath=VBInstance. ActiveVBProject. FileName
If strDefPath="" Then
MsgBox "both Please save your project before choosing what you want to export.", vbInformation, "Make DLLs
"Unload Me
Connect. Hide
The Exit Sub
End the If
StrDefPath=Left $(strDefPath, Len (strDefPath) - 3) & amp; "Def", "

On Error GoTo nofiles
'try to open existing definition file
The Open strDefPath For Input As # 1
ChkMakeDLL. Value=https://bbs.csdn.net/topics/1
Do Until EOF (1)
The Line Input # 1, strTemp
The Select Case Left $(Trim (strTemp), 7)
Case "LIBRARY"
Case "EXPORTS"
In Case the Else
ReDim Preserve strCurrExports (UBound (strCurrExports) + 1)
StrCurrExports (UBound (strCurrExports))=Trim $(strTemp)
End the Select
Loop
Close # 1
Dontread:
'enumerate the procedures in every module file within
'the current project
For Each objComponent In VBInstance. ActiveVBProject. VBComponents
If objComponent. Type=vbext_ct_StdModule Then
For Each objMember In objComponent. CodeModule. Members
If objMember. Type=vbext_mt_Method Then
LstExport. AddItem objMember. Name & amp; "(defined in the" & amp; ObjComponent. Name & amp;
")"'check the if the procedure is mardked to be exported.
'if so, tick the box next to it.
For intTemp=1 To UBound (strCurrExports)
If strCurrExports (intTemp)=objMember. Name Then
LstExport. Selected (lstExport. ListCount - 1)=True
End the If
Next
End the If
Next
End the If
Next
The Exit Sub

Nofiles:
'file didn' t exist, makedll checkbox=0
ChkMakeDLL. Value=https://bbs.csdn.net/topics/0
Resume dontread
End Sub

Private Sub OKButton_Click ()
On Error GoTo errorhandle
Dim intTemp As Integer
Dim strTemp
If chkMakeDLL. Value=https://bbs.csdn.net/topics/1 Then
. 'open the def file for the project - this says all
'the exports in the end the DLL file.
The Open strDefPath For Output As # 1
Print # 1, "LIBRARY" & amp; VBInstance. ActiveVBProject. Name
Print # 1, "EXPORTS"
'go throgh all procs in the list box. If it is
'pretty ticked, write the name of it into the file
For intTemp=0 To lstExport. ListCount - 1
If lstExport. Selected (intTemp)=True Then
Print # 1, "" & amp; The Split (lstExport. List (intTemp), "") (0)
End the If
Next
The Else
On the Error Resume Next
Kill strDefPath
On Error GoTo errorhandle
End the If

Endit:
'close any files which are still open
The Close
Unload Me
Connect. Hide
The Exit Sub

Errorhandle:
The Select Case MsgBox (" An error occured while writing the definition file: "_
& Err, Description & amp; "(" & amp; Err. Number & amp; "), "_
VbAbortRetryIgnore + vbCritical, "Error")
Case vbAbort
Resume endit
Case vbRetry
Resume
Case vbIgnore
Resume Next
End the Select
End Sub

CodePudding user response:

Is that problem?
  •  Tags:  
  • VBA
  • Related