×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

error msg:close topmost modal form

error msg:close topmost modal form

error msg:close topmost modal form

(OP)
I'm attempting to write a vba program to open all the drawings in a directory. It opens the first drawing fine, but after opening the second drawing it gives me an error message "must close or hide topmost modal form first".

Here is the code:

Public Sub OpenDwgs()
DirName = "K:\_a\A05309\"
DwgNames(1) = "A0530912"
DwgNames(2) = "A0530913"
DwgNames(3) = "A0530914"
For i = 1 To 3
DwgName = DirName & DwgNames(i) & ".dwg"
MsgBox DwgName
Set CurrentDwg = Application.Documents.Open(DwgName)
'(code goes here)
CurrentDwg.Close
Next i
End Sub

Any ideas what the problem is??

RE: error msg:close topmost modal form

(OP)
Thanks for the help
This how I got around it....

' In order for this to work the Microsoft Scripting Runntime reference must be added to the project
Dim FileItem As File
Dim SourceFolder As Scripting.Folder
Dim FSO As Scripting.FileSystemObject
Public Sub OpenDwgs()
Set FSO = New Scripting.FileSystemObject
Set SourceFolder = FSO.GetFolder(mypath)
r = 0
For Each FileItem In SourceFolder.Files
r = r + 1
Set FSO = New Scripting.FileSystemObject
Set SourceFolder = FSO.GetFolder(mypath)
If Right$(FileItem.Name, 4) = ".dwg" Then
Set CurrentDwg = Application.Documents.Open(mypath & FileItem.Name)
Call DoSomething
ThisDrawing.Close
End If
Next
End Sub

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources