PDA

View Full Version : Pop ups



knobloch.b
02-18-2010, 08:05 AM
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.

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

lucas
02-18-2010, 08:18 AM
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:

Application.DisplayAlerts = False

knobloch.b
02-18-2010, 08:20 AM
I will try that thank you.

knobloch.b
02-18-2010, 08:31 AM
That would be a no :whyme:. But it was worth a shot

lucas
02-18-2010, 10:32 AM
Maybe add an errorhandler to see what's going on?

On Error GoTo 1
ActiveWorkbook.FollowHyperlink (ActiveWorkbook.Path & "\TestDoc.doc"), NewWindow:=True
Exit Sub
1: MsgBox Err.Description

knobloch.b
02-18-2010, 12:19 PM
Said couldn't find the file? Is there another way to open a file that is in a different program?

lucas
02-18-2010, 12:30 PM
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.

lucas
02-18-2010, 12:33 PM
another question: if you double click the file

Ribbed ribbed steel packing.iam

from windows explorer, does it open in Inventor?

knobloch.b
02-18-2010, 12:54 PM
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?

Aussiebear
02-18-2010, 07:51 PM
Did you change the file name in the error handler?

knobloch.b
02-19-2010, 06:17 AM
I retried it and nothing still getting the window and i think i have an extra folder create?

Bob Phillips
02-19-2010, 06:28 AM
What type of file is an iam file?

knobloch.b
02-19-2010, 07:04 AM
It is an Inventor Assembly File. It is a 3D molding software

efz
03-03-2010, 02:48 PM
lol tricky one!

knobloch.b
03-12-2010, 02:48 PM
Yes it is a very tricky one

lucas
03-12-2010, 03:00 PM
Does inventor have a vba interface?

knobloch.b
03-15-2010, 04:54 AM
It has one like the excel version. If that helps?

lucas
03-15-2010, 08:07 AM
If it has a vba interface then the call to:


Application.DisplayAlerts = False

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:
Application.DisplayAlerts = wdAlertsNone

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.

Paul_Hossler
03-22-2010, 04:07 PM
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


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


Paul

knobloch.b
04-19-2010, 01:27 PM
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