Consulting

Results 1 to 20 of 20

Thread: Pop ups

  1. #1

    Pop ups

    Ok so I have a 100 line macro that I built by using sample code I found here. It does what I programmed it to surprisingly. The engineer above me wants to get ride of the windows that keep popping up. So here is what the macro does. Someone puts an order in for a part. An employee opens the excel file takes down the dimensions of what the customer wants. Clicks a button and the file saves it self a screen pops up and asks for a part number and 8 different check boxes. Depending on which 3 of 8 they pick the computer will go and find the required drawings and assembly files in Inventor and proceed to open them. This is where I get the pop up that slows the whole process down. Is there any way around this pop up? And the fact that there are 16 cases and i only show one is that its the same thing over and over.

    [vba]Private Sub cmdOK_Click()
    RefrPN = Me.TextBox1.Text


    Dim Part As Integer

    'Checking For Folder and creating folder if its not there
    Dim FSO1 As Object
    Dim FSO As Object
    Dim FromPath As String
    Dim ToPath As String
    Dim folder As String
    folder = "C:\Documents and Settings\brianK\My Documents\" & RefrPN
    Set FSO = CreateObject("Scripting.FileSystemObject")
    If FSO.FolderExists(test) Then
    MsgBox& "is a valid folder.", vbInformation, "Path Exists"

    End If

    If CheckBox1.Value And CheckBox3.Value And CheckBox5.Value = True Then Part = 1 Else

    If CheckBox1.Value And CheckBox3.Value And CheckBox6.Value = True Then Part = 2 Else
    If CheckBox1.Value And CheckBox3.Value And CheckBox7.Value = True Then Part = 3 Else
    If CheckBox1.Value And CheckBox3.Value And CheckBox8.Value = True Then Part = 4 Else
    If CheckBox1.Value And CheckBox4.Value And CheckBox5.Value = True Then Part = 6 Else
    If CheckBox1.Value And CheckBox4.Value And CheckBox6.Value = True Then Part = 7 Else
    If CheckBox1.Value And CheckBox4.Value And CheckBox7.Value = True Then Part = 8 Else
    If CheckBox1.Value And CheckBox4.Value And CheckBox8.Value = True Then Part = 5 Else
    If CheckBox2.Value And CheckBox3.Value And CheckBox5.Value = True Then Part = 9 Else
    If CheckBox2.Value And CheckBox3.Value And CheckBox6.Value = True Then Part = 10 Else
    If CheckBox2.Value And CheckBox3.Value And CheckBox7.Value = True Then Part = 11 Else
    If CheckBox2.Value And CheckBox3.Value And CheckBox8.Value = True Then Part = 12 Else
    If CheckBox2.Value And CheckBox4.Value And CheckBox5.Value = True Then Part = 14 Else
    If CheckBox2.Value And CheckBox4.Value And CheckBox6.Value = True Then Part = 15 Else
    If CheckBox2.Value And CheckBox4.Value And CheckBox7.Value = True Then Part = 16 Else
    If CheckBox2.Value And CheckBox4.Value And CheckBox8.Value = True Then Part = 13 Else



    'Copying files from School Ribbed Steel to Created folder
    Select Case Part

    Case Is = 1
    FromPath = "C:\Documents and Settings\brianK\Desktop\School Ribbed Steel"
    ToPath = "C:\Documents and Settings\brianK\My Documents\" & RefrPN

    If Right(FromPath, 1) = "C:\Documents and Settings\brianK\Desktop\School Ribbed Steel" Then
    FromPath = Left(FromPath, Len(FromPath) - 1)
    End If

    If Right(ToPath, 1) = "C:\Documents and Settings\brianK\My Documents\" & RefrPN Then
    ToPath = Left(ToPath, Len(ToPath) - 1)
    End If

    Set FSO1 = CreateObject("scripting.filesystemobject")

    If FSO1.FolderExists(FromPath) = False Then
    MsgBox FromPath & " doesn't exist"
    End If

    FSO1.CopyFolder Source:=FromPath, Destination:=ToPath

    ActiveWorkbook.SaveAs Filename:= _
    "C:\Documents and Settings\brianK\My Documents\" & RefrPN & "\Excel Driver Page.xls" _
    , FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False

    MsgBox "You can find the files and subfolders from " & "Template Folder" & " in " & RefrPN


    'Opening Inventor for checking and printing drawings
    ActiveWorkbook.FollowHyperlink "C:\Documents and Settings\brianK\My Documents\" & RefrPN & _
    "\Ribbed ribbed steel packing.iam", NewWindow:=True
    ActiveWorkbook.FollowHyperlink "C:\Documents and Settings\brianK\My Documents\" & RefrPN & _
    "\Ribbed Ribbed Steel.idw", NewWindow:=True
    ActiveWorkbook.FollowHyperlink "C:\Documents and Settings\brianK\My Documents\" & RefrPN & _
    "\Steel Flat Pattern.idw", NewWindow:=True
    ActiveWorkbook.FollowHyperlink "C:\Documents and Settings\brianK\My Documents\" & RefrPN & _
    "\Rib Tread.idw", NewWindow:=True[/vba]

  2. #2
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    One suggestion would be to shut off the display of alerts just before that section of code runs. You need to set it back to true after that code runs though:

    [vba]Application.DisplayAlerts = False[/vba]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  3. #3
    I will try that thank you.

  4. #4
    That would be a no . But it was worth a shot

  5. #5
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Maybe add an errorhandler to see what's going on?

    [VBA] On Error GoTo 1
    ActiveWorkbook.FollowHyperlink (ActiveWorkbook.Path & "\TestDoc.doc"), NewWindow:=True
    Exit Sub
    1: MsgBox Err.Description[/VBA]
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  6. #6
    Said couldn't find the file? Is there another way to open a file that is in a different program?

  7. #7
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    This is the best way I think. If it can't find the file, might there be a problem with your path?

    Can you put a file in a simpler path to test it?

    Mayber try a doc file or something just to see what is going on.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  8. #8
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    another question: if you double click the file

    Ribbed ribbed steel packing.iam

    from windows explorer, does it open in Inventor?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  9. #9
    Yes the program will open from explorer. Im just trying to automate it so that you dont have to go looking. It worked before i tried the error handler. Maybe i typed it wrong?

  10. #10
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,055
    Location
    Did you change the file name in the error handler?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  11. #11
    I retried it and nothing still getting the window and i think i have an extra folder create?

  12. #12
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    What type of file is an iam file?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  13. #13
    It is an Inventor Assembly File. It is a 3D molding software

  14. #14
    lol tricky one!

  15. #15
    Yes it is a very tricky one

  16. #16
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Does inventor have a vba interface?
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  17. #17
    It has one like the excel version. If that helps?

  18. #18
    Moderator VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    If it has a vba interface then the call to:
    [VBA]
    Application.DisplayAlerts = False
    [/VBA]
    may be different and you should be able to research it in the help files in the inventor vb editor.

    For instance, in Word it looks like this:
    [VBA]Application.DisplayAlerts = wdAlertsNone[/VBA]

    If you have intellisense turned on you should be able to type:

    application.displayalerts =

    When you type the = sign or the space after it, intellisense should give you some options.

    Hope this helps.
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

  19. #19
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,724
    Location
    I'm not a big fan of SendKeys but I inserted a hyperlink into a worksheet to call a txt file

    Just clicking it got the Security popup. but linking to it from my VBA below bypassed the popup

    [vba]
    Sub Macro1()
    Call Application.SendKeys("%y")
    Range("G5").Hyperlinks(1).Follow NewWindow:=False, AddHistory:=True
    End Sub
    [/vba]

    Paul

  20. #20
    Ok paul That seems like a good idea but i have no idea how to get around the range part. But the company I work for changed its idea of what they wanted it to do and after removing the hyperlink my program works. Thanks for all the help yall
    Last edited by knobloch.b; 04-20-2010 at 08:46 AM.

Posting Permissions

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