Instr Help (1 Viewer)

frustrating

Registered User.
Local time
Today, 08:56
Joined
Oct 18, 2012
Messages
68
I'm trying to code something that scans for different files and automatically opens them.

For example: 99 times out of 100, the file is going to be a pdf, so I made this code:

Code:
OID = IeApp.Document.body.innerHTML
OIDLEFT = Mid(OID, InStr(1, OID, "oid") + 4, 9) 'this scans the source code for a number i use to compile a link

Sprofile = IeApp.Document.body.innerText
totheleft = Mid(Sprofile, InStr(1, Sprofile, "sdrop event") + 12)
thekey = Left(totheleft, InStr(1, totheleft, "pdf") - 2)
thelink = "Link" & thekey & ".pdf" & "?oid=" & OIDLEFT & "&filename=" & thekey & ".pdf"
removespace = Replace(thelink, " ", "")
With IeApp
IeApp.navigate removespace
End With
What I'd like to be able to do is make it so if this fails to retrieve a pdf, to then search for a jpg, tif, or zip.

Any ideas on the best solution?
 

frustrating

Registered User.
Local time
Today, 08:56
Joined
Oct 18, 2012
Messages
68
I think I solved my issue.

I created conditional statements that each search for the specific string. I thought there may be an easier way, but nope!
 

pr2-eugin

Super Moderator
Local time
Today, 16:56
Joined
Nov 30, 2011
Messages
8,494
Hello frustrating, I am not sure, but I cannot understand your code.. If you could give some sample data and explain in simple plain English what you want to do some of us could help out..
 

Users who are viewing this thread

Top Bottom