ext = UCase$(ext) - I'm assuming "ext" has been defined elsewhere in the code to be the file extension. This line is setting it to be uppercase
swDocTypeLong = Switch(ext = ".SLDDRW", swDocDRAWING, True, -1) - This is checking to see if the file extension is for a Drawing. If it is, then "swDocTypeLong" is set to match a drawing document, otherwise it is set to "-1".
If swDocTypeLong = -1 Then - This is checking to see if "swDocTypeLong" was set to "-1" in the previous line
Exit Sub - This exits the sub if the previous line was true
You could do the same thing by using:
If UCase$(ext) = ".SLDDRW" Then
swDocTypeLong = swDocDrawing
swDocTypeLong = -1
Or you could simplify it even more if swDocTypeLong is only being used in this sub:
If Not UCase$(ext) = ".SLDDRW" Then
Thank you for the quick reply Pat. I was looking over this and I really felt like I was misunderstanding it. I have very limited knowlege of VBA and I when I look at this i cant help thinking there is an extra line in here.
I think I might just have misunderstood the Switch function. I feel like this would still net the same result.
Dim swDocTypeLong As Long
swDocTypeLong = Switch(ext = ".slddrw", swDocDRAWING, True, -1)
If swDocTypeLong = -1 Then
Sometimes files will have the extension in uppercase, and sometimes they will be in lowercase. The VBA code is case sensitive, so they have to match exactly.
ext = UCase$(ext)
makes sure the extension is in all uppercase to match the string it is being compared to.