Message 1 of 5
write to file in notepad from combo select

Not applicable
06-20-2002
08:46 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
Just playing with a file compostion program attempt.
objective:
select item in combo box
enter that item at selected location in text file open in notepad
- or open in any other way of viewing a file - like opening in a giant input
box or ???
some way to mimic a notepad like window on a form???
I can fill a combo box from the contents of a text file thusly:
Private Sub PopulateComboBoxFromFile(fname As String, cboObject As ComboBox)
Dim fNum As Integer
fNum = FreeFile
Open fname For Input As #fNum 'Open file for input
Do While Not EOF(fNum) 'Loop until end of file
cboObject.AddItem ReadLineFromFile(ByVal fNum)
Loop
Close #fNum 'Close file
End Sub
Public Function ReadLineFromFile(ByVal fNum As Integer) As String
Dim ThisLine As String
Input #fNum, ThisLine 'Read data into variable
ReadLineFromFile = ThisLine
End Function
Now I open a file in notepad thusly:
Function OpenNotepadTextfile(fullPathName As String) As App ' not sure about
this return type
Dim myappid As Variant
Dim appname As Variant '(1) As Variant
appname = "C:\Windows\notepad.EXE " & fullPathName
myappid = Shell(appname, 1) 'vbMaximizedFocus) ' Run notepad
AppActivate myappid ' Activeate notepad
'now I'm not sure what i want to pass back to the calling sub
'I want to be able to refer to and manipulate this now open file from other
subs
'so I need some reference to it, not sure if this does it for me:
OpenNotepadTextfile = myappid
End Function
'Now I want to be able in some sub to do various things such as:
'''
Function PutFocusInThisFile (ThisFile as fileobject or filename?)as boolean
'get focus on that open file in notepad
PutFocusInThisFile = error-or-not 'return something so I know if theres
problem or not
End Function
'''
Function MoveCursor (ThisFile as fileobject or filename?, ThatDirection as
?, SomeDistance as ?) as boolean
'move cursor in ThisFile by SomeDistance in ThatDirection
MoveCursor = error-or-not 'return something so I know if theres problem or
not
End Function
'''
Function EnterData (sThisFile as Fileobject or filename?, sData as String)
as boolean
'enter string data at current cursor position
EnterData = error-or-not 'return something so I know if theres problem or
not
End Function
'''
is any of this possible or hopefully even easy??? with vb? or do I need to
learn how to do api calls?
Any ideas, help or inspiration appreciated.
Mark
Just playing with a file compostion program attempt.
objective:
select item in combo box
enter that item at selected location in text file open in notepad
- or open in any other way of viewing a file - like opening in a giant input
box or ???
some way to mimic a notepad like window on a form???
I can fill a combo box from the contents of a text file thusly:
Private Sub PopulateComboBoxFromFile(fname As String, cboObject As ComboBox)
Dim fNum As Integer
fNum = FreeFile
Open fname For Input As #fNum 'Open file for input
Do While Not EOF(fNum) 'Loop until end of file
cboObject.AddItem ReadLineFromFile(ByVal fNum)
Loop
Close #fNum 'Close file
End Sub
Public Function ReadLineFromFile(ByVal fNum As Integer) As String
Dim ThisLine As String
Input #fNum, ThisLine 'Read data into variable
ReadLineFromFile = ThisLine
End Function
Now I open a file in notepad thusly:
Function OpenNotepadTextfile(fullPathName As String) As App ' not sure about
this return type
Dim myappid As Variant
Dim appname As Variant '(1) As Variant
appname = "C:\Windows\notepad.EXE " & fullPathName
myappid = Shell(appname, 1) 'vbMaximizedFocus) ' Run notepad
AppActivate myappid ' Activeate notepad
'now I'm not sure what i want to pass back to the calling sub
'I want to be able to refer to and manipulate this now open file from other
subs
'so I need some reference to it, not sure if this does it for me:
OpenNotepadTextfile = myappid
End Function
'Now I want to be able in some sub to do various things such as:
'''
Function PutFocusInThisFile (ThisFile as fileobject or filename?)as boolean
'get focus on that open file in notepad
PutFocusInThisFile = error-or-not 'return something so I know if theres
problem or not
End Function
'''
Function MoveCursor (ThisFile as fileobject or filename?, ThatDirection as
?, SomeDistance as ?) as boolean
'move cursor in ThisFile by SomeDistance in ThatDirection
MoveCursor = error-or-not 'return something so I know if theres problem or
not
End Function
'''
Function EnterData (sThisFile as Fileobject or filename?, sData as String)
as boolean
'enter string data at current cursor position
EnterData = error-or-not 'return something so I know if theres problem or
not
End Function
'''
is any of this possible or hopefully even easy??? with vb? or do I need to
learn how to do api calls?
Any ideas, help or inspiration appreciated.
Mark