PDA

View Full Version : Shortwrite



Emperor
01-18-2010, 05:30 AM
Dear VBA-guru's,

I am looking for a way to shorten the next code, this is only a small part from the real code:
If TextBox3.Value = 11 Then
Selection.InsertFile FileName:="11.doc", Range:="", ConfirmConversions:= _
False, Link:=False, Attachment:=False
End If
If TextBox3.Value = 12 Then
Selection.InsertFile FileName:="12.doc", Range:="", ConfirmConversions:= _
False, Link:=False, Attachment:=False
End If
If TextBox3.Value = 13 Then
Selection.InsertFile FileName:="13.doc", Range:="", ConfirmConversions:= _
False, Link:=False, Attachment:=False
End If
If TextBox3.Value = 14 Then
Selection.InsertFile FileName:="14.doc", Range:="", ConfirmConversions:= _
False, Link:=False, Attachment:=False
End If

Thnx in advance

Emperor

Jan Karel Pieterse
01-18-2010, 05:55 AM
'Test for validity of content of textbox3 goes here!
Selection.InsertFile FileName:=TextBox3.Value & ".doc", Range:="", ConfirmConversions:= _
False, Link:=False, Attachment:=False

Emperor
01-18-2010, 06:01 AM
Jan Karel,

Thank you, this was what I was looking for, it was a lot more easy than that I figured ^^