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..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, "\")) destinTXT = Replace(destinTXT, "pdf", "txt") 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
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.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
Any thoughts or ideas are greatly appreciated! Thanks in advance..
Last edited by hoffey; 07-20-2009 at 03:30 PM.
This fixed it.. Sorry for the post! I guess sometimes you just have to ask the question..
Code:destinLOC = Filename destinLOC = Replace(destinLOC, "pdf", "txt") destinPLN = Right(Filename, Len(Filename) - InStrRev(Filename, "\")) destinPLN = Replace(destinPLN, ".pdf", "") destinPLN = Replace(destinPLN, " ", "") destinTXT = Right(Filename, Len(Filename) - InStrRev(Filename, "\")) destinTXT = Replace(destinTXT, "pdf", "txt") destinTXT = Replace(destinTXT, " ", "")
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks