scriptscribe
MIS
Hi fellas, I have an interesting quandry. Because of the security profiles of my company's network, I'm not able to access (upload/write to) any files via VBA. So the only way for me to write to our computer system via VBA is for me to cut and paste the entire text file in my code. I know...sucks for me.
My data looks like this:
NAME: SMITH MD,DAVID
NUMERIC CODE: 999
MNEMONIC: SMID
DIVISION: ANESTHESIOLOGY
BILLING AREA(S): ANESTHESIA SVCS
BILLING AREA(S): SUPPLY
LOCATION(S): INPATIENT
LOCATION(S): OUTPATIENT
Normally to access something like this from a network, I'd write code similar to this:
So I'll just have about a hundred entries (at least) like the one above, that I'll need to loop through until I reach the next field that reads "Name:", which of course will signify the next doctor entry.
My question is, how do I identify the data (readline)when it's inside the VBA code, write the data after the ":" (not sure if I used Instr correctly) and loop through it?
I'm a bit new to VBA, so any help will be appreciated. I'm familiar with the basics, but this one has thrown me for a loop, as at previous companies I've always linked to spreadsheets or text files on the network drives.
Thanks,
Mike
My data looks like this:
NAME: SMITH MD,DAVID
NUMERIC CODE: 999
MNEMONIC: SMID
DIVISION: ANESTHESIOLOGY
BILLING AREA(S): ANESTHESIA SVCS
BILLING AREA(S): SUPPLY
LOCATION(S): INPATIENT
LOCATION(S): OUTPATIENT
Normally to access something like this from a network, I'd write code similar to this:
Code:
Sub ImportFile()
Dim fs As FileSystemObject
Dim f As TextStream
Set fs = CreateObject("Scripting.FileSystemObject")
strFileIn = "T:\strText.txt"
Set fin = fs.OpenTextFile(strFileIn)
Do While f.AtEndOfStream <> True
lin = f.ReadLine
If Trim(lin) Like "Billing Area:*" Then
strLine1 = Trim(Right((lin), InStr(":", 1), 15))
f.WriteLine strLine1
If Trim(lin) Like "Name:*" Then
strLine1 = Trim(Right((lin), InStr(":", 1), 25))
f.WriteLine strLine1
End If
End If
Loop
f.Close
Set f = Nothing
Set fs = Nothing
End Sub
So I'll just have about a hundred entries (at least) like the one above, that I'll need to loop through until I reach the next field that reads "Name:", which of course will signify the next doctor entry.
My question is, how do I identify the data (readline)when it's inside the VBA code, write the data after the ":" (not sure if I used Instr correctly) and loop through it?
I'm a bit new to VBA, so any help will be appreciated. I'm familiar with the basics, but this one has thrown me for a loop, as at previous companies I've always linked to spreadsheets or text files on the network drives.
Thanks,
Mike