0
votes

So i am trying to make this program open a file that the user chooses so i have them first enter their file that is already on the desktop and put the .txt extension after the name and then i try to add the name at the end of the directory and it says on line: 10 column: 1 Type mismatch any help would be appreciated thanks. I am new to this :)

Option Explicit
Dim a, b, c, d, e

Set a = createobject("wscript.shell")

c = msgbox("Welcome to my word finding program!", vbInformation+vbOkCancel+vbDefaultButton1+vbSystemModal, "Information: ")

b = inputbox("MAKE SURE THAT YOUR FILE IS ON YOUR DESKTOP!" &vbLf& "Please enter the name of your .txt file" &vbLf& "Rembmer to add .txt after it" &vbLf& "EX: Name.txt")


a.run"C:\Users\%username%\Desktop\", b
1
great variable naming, BTW. - Mitch Wheat

1 Answers

2
votes
  1. Space is missing after a.run
  2. http://msdn.microsoft.com/en-us/library/d5fk67ky%28v=vs.84%29.aspx
    Folder and filename are not two seperate parameters.
    a.run "C:\Users\%username%\Desktop\" & b
  3. However, path and filename might contain spaces, so you should always quote them (quotes inside strings are written as two quotes)

    a.run """C:\Users\%username%\Desktop\" & b & """"