I'm not sure why but the following code results in an error when the file you point to includes spaces. It works fine otherwise.
Any thoughts? I'm thinking maybe I can replace the spaces with nil?
This is the result of the debug immediately after the bolded line above..
The error is occurring during the Workbooks.OpenText event. I'm assuming it has to do with passing the wrong arguments to the Shell event in which case there is nothing for it to open. Actually, I'm certain that is what is happening.
Any thoughts or ideas are greatly appreciated! Thanks in advance..
Any thoughts? I'm thinking maybe I can replace the spaces with nil?
Code:
Filename = Application.GetOpenFilename("Adobe PDF (*.pdf),*.pdf")
destinLOC = Filename
destinLOC = Replace(destinLOC, "pdf", "txt")
destinPLN = Right(Filename, Len(Filename) - InStrRev(Filename, "\"))
destinPLN = Replace(destinPLN, ".pdf", "")
destinTXT = Right(Filename, Len(Filename) - InStrRev(Filename, "\"))
[B]destinTXT = Replace(destinTXT, "pdf", "txt")[/B]
taskid = Shell("C:\pdf\pdftotext.exe " & Chr(34) & Filename & Chr(34) & " " & destinTXT, vbNormalFocus)
WAIT = Timer
While Timer < WAIT + 2
DoEvents 'do nothing
Wend
'Importation
'destinTXT is the source below for some unexplained reason :)
Workbooks.OpenText Filename:=destinTXT, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, Comma:=False, _
Space:=True, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3 _
, 1)), TrailingMinusNumbers:=True
This is the result of the debug immediately after the bolded line above..
Code:
Debug.Print destinTXT
Jun 09 PSR Lvl 2.txt
Debug.Print destinLOC
C:\Jun 09 PSR Lvl 2.txt
debug.Print destinPLN
Jun 09 PSR Lvl 2
The error is occurring during the Workbooks.OpenText event. I'm assuming it has to do with passing the wrong arguments to the Shell event in which case there is nothing for it to open. Actually, I'm certain that is what is happening.
Any thoughts or ideas are greatly appreciated! Thanks in advance..