ozone7
asked on
Writing to a Text File on C Drive
I am trying to Write the information from a Particular Field (permapf_ in a DOC to a Text File on the C drive usingthe Open for Append.. I cannot get the code to work and get Variant Deos not Contain an Object error.. I am not sure that I have coded the Script right.. Can anyone help. Here is the code. I am tring to get a field called permapf to write to the text file! I am new to Scripts and have used functions most of the time, so I am lost!!
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim permapf As String
Dim item As NotesItem
Set doc = workspace.CurrentDocumet
Set item = doc.GetFirstItem("permapf" )
Set doc = workspace.CurrentDocumet
fileNum% = Freefile()
fileName$ = "c:\apf.txt"
' Write permapf field contents
Open fileName$ For Append As fileNum%
Write #fileNum%, doc.permapf
Close fileNum%
End Sub
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim permapf As String
Dim item As NotesItem
Set doc = workspace.CurrentDocumet
Set item = doc.GetFirstItem("permapf"
Set doc = workspace.CurrentDocumet
fileNum% = Freefile()
fileName$ = "c:\apf.txt"
' Write permapf field contents
Open fileName$ For Append As fileNum%
Write #fileNum%, doc.permapf
Close fileNum%
End Sub
ASKER
I sm still getting Object vairable not Set.. My entire logic here may be wrong.. :-( This is what I have .. Do you have any code that will write the contents of a Field to a Text File?? Help!! I work on the MVS side and do tis Notes Stuff as a side Item. I like it, but the Scritping confuses me!!!!
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim permapf As String
Dim item As NotesItem
Dim workspace As New NotesUIWorkspace
Set item = doc.GetFirstItem("permapf" )
fileNum% = Freefile()
fileName$ = "c:\apf.txt"
' Write permapf field contents
Open fileName$ For Append As fileNum%
Write #fileNum%, doc.permapf(0)
Close fileNum%
End Sub
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim permapf As String
Dim item As NotesItem
Dim workspace As New NotesUIWorkspace
Set item = doc.GetFirstItem("permapf"
fileNum% = Freefile()
fileName$ = "c:\apf.txt"
' Write permapf field contents
Open fileName$ For Append As fileNum%
Write #fileNum%, doc.permapf(0)
Close fileNum%
End Sub
Now you left something out too much, you didn't get the document:
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim permapf As String
Dim item As NotesItem
Dim workspace As New NotesUIWorkspace
Set doc = workspace.CurrentDocument
Set item = doc.GetFirstItem("permapf" )
fileNum% = Freefile()
fileName$ = "c:\apf.txt"
' Write permapf field contents
Open fileName$ For Append As fileNum%
Write #fileNum%, doc.permapf(0)
Close fileNum%
End Sub
I assume this is code in a button or action?
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim view As NotesView
Dim doc As NotesDocument
Dim permapf As String
Dim item As NotesItem
Dim workspace As New NotesUIWorkspace
Set doc = workspace.CurrentDocument
Set item = doc.GetFirstItem("permapf"
fileNum% = Freefile()
fileName$ = "c:\apf.txt"
' Write permapf field contents
Open fileName$ For Append As fileNum%
Write #fileNum%, doc.permapf(0)
Close fileNum%
End Sub
I assume this is code in a button or action?
ASKER
Yes, it is a button on the Form!! I am getting errors on this statement
Set doc = workspace.CurrentDocument
Getting Type Mismatch on CurrentDocument!!
Set doc = workspace.CurrentDocument
Getting Type Mismatch on CurrentDocument!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
doc is a NotesDocuemnt (data record). workspace.currentDocument returns a notesUIDocument (basically the on-screen form, which can display a representation of a data document).
As partha suggests, you need to get the notesDocuemnt taht the on-screen form represents, and notesUiDocument.document gives you that (or, workspace.currentDocument. document in your code).
Also, you redundantly set the doc variable twice.
Finally, doc.permapf returns the value of a document field. Notes always returns those as an array, even if there is only one value. So you really need Write #fileNum%, doc.permapf(0) -- which Sjef noticed. I hope he feels better.
As partha suggests, you need to get the notesDocuemnt taht the on-screen form represents, and notesUiDocument.document gives you that (or, workspace.currentDocument.
Also, you redundantly set the doc variable twice.
Finally, doc.permapf returns the value of a document field. Notes always returns those as an array, even if there is only one value. So you really need Write #fileNum%, doc.permapf(0) -- which Sjef noticed. I hope he feels better.
Hmm. Don't you think a split of the points would have been a lot fairer? My bro Partha is probably ROFL at the moment... A moment he may enjoy, but not for too long.
(Q: I can handle critique, if that's what you mean. Referring to what actually? I haven't read a lot of EE mails yet :-| )
(Q: I can handle critique, if that's what you mean. Referring to what actually? I haven't read a lot of EE mails yet :-| )
OH MY GOD, It should have been a split ...I don't want to fight with my bro , if you are not giving points, i am giving him
Partha
Partha
Just noticed today -- I broke 1MM overall, but not in this topic.
I hope it makes you feel better ;)
Congratulations! Yet another 1E5 points to prove you're a Domino Genius.
Congratulations! Yet another 1E5 points to prove you're a Domino Genius.
Congrats Qwal, You are one of our "Gurus" here
Partha
Partha
Please ozone7, would you be so kind to reconsider the way you dealt your points in this question?
ASKER
????? Not Exactly Sure what you mean!!
How tragic. Forget it. Partha my bro, don't even think about donating points!
Ozone7
It was Sjef who gave you the answer, I just gave you the direction to fix it properly.....So ideally he should have got the points. Pls give him some points or i will be giving him for htis questions ..
Bro,
No donations, you deserve it :)
Partha
It was Sjef who gave you the answer, I just gave you the direction to fix it properly.....So ideally he should have got the points. Pls give him some points or i will be giving him for htis questions ..
Bro,
No donations, you deserve it :)
Partha
ASKER
Not sure how to do that.. Can you transfer points?? Tell me how!!
Some syntax errors corrected:
> Dim db As NotesDatabase
> Dim view As NotesView
> Dim doc As NotesDocument
> Dim permapf As String
> Dim item As NotesItem
Dim workspace As New NotesUIWorkspace
Set doc = workspace.CurrentDocument
> Set item = doc.GetFirstItem("permapf"
' Set doc = workspace.CurrentDocument ' already done
> fileNum% = Freefile()
> fileName$ = "c:\apf.txt"
> ' Write permapf field contents
> Open fileName$ For Append As fileNum%
Write #fileNum%, doc.permapf(0)
>
> Close fileNum%
> End Sub
Try this first.
Cheers!
Sjef