I have some code below:
Sub SystemInfoInput()
Dim myFile As String, text As String, textline As String, posLat As Integer, posLong As Integer
myFile = "C:\Temp\systeminfo.txt"
Open myFile For Input As #1
Do Until EOF(1)
Line Input #1, textline
text = text & textline
Loop
Close #1
TotMem = InStr(text, "Total Physical Memory")
SysMod = InStr(text, "System Model")
Range("D4").Value = Mid(text, TotMem + 27, 8)
Range("D5").Value = Mid(text, SysMod + 27, 19)
End Sub
I want it to return the value after Total Physical Memory: (currently have it above by using the characters but as this will be run on different machines these values will change and the character length not always correct).
At the moment i am trying to get it to return a few lines but i will want to return more than i currently have got.
Here is a snippet of the file it is opening:
OS Name: Microsoft Windows 7 Enterprise
OS Version: 6.1.7601 Service Pack 1 Build 7601
OS Manufacturer: Microsoft Corporation
OS Configuration: Member Workstation
OS Build Type: Multiprocessor Free
Registered Owner: Computer User
Original Install Date: 12/07/2016, 15:28:21
System Boot Time: 25/08/2017, 10:43:46
System Manufacturer: HP
System Model: HP EliteBook 850
System Type: X86-based PC
Processor(s): 1 Processor(s) Installed.
[01]: x64 Family 6 Model 78 Stepping 3 GenuineIntel ~2277 Mhz
BIOS Version: HP N75 Ver. 01.16, 08/06/2017
Windows Directory: C:\WINDOWS
System Directory: C:\WINDOWS\system32
Boot Device: \Device\HarddiskVolume1
System Locale: en-gb;English (United Kingdom)
Input Locale: en-gb;English (United Kingdom)
Time Zone: (UTC+00:00) Dublin, Edinburgh, Lisbon, London
Total Physical Memory: 3,185 MB
Any suggestions on how i can improve the code would be greatly appreciated!
Bookmarks