Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 359
  • Last Modified:

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

0
ozone7
Asked:
ozone7
  • 6
  • 4
  • 4
  • +1
1 Solution
 
Sjef BosmanGroupware ConsultantCommented:
Hi ozone7,

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
0
 
ozone7Author Commented:
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
0
 
Sjef BosmanGroupware ConsultantCommented:
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?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ozone7Author Commented:
Yes, it is a button on the Form!! I am getting errors on this statement
Set doc = workspace.CurrentDocument

Getting Type Mismatch on CurrentDocument!!
0
 
p_parthaCommented:
set doc = workspace.currentdocument.document

Partha
0
 
qwaleteeCommented:
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.
0
 
Sjef BosmanGroupware ConsultantCommented:
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 :-| )
0
 
p_parthaCommented:
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
0
 
qwaleteeCommented:
Just noticed today -- I broke 1MM overall, but not in this topic.
0
 
Sjef BosmanGroupware ConsultantCommented:
I hope it makes you feel better ;)

Congratulations! Yet another 1E5 points to prove you're a Domino Genius.
0
 
p_parthaCommented:
Congrats Qwal, You are one of our "Gurus" here

Partha
0
 
Sjef BosmanGroupware ConsultantCommented:
Please ozone7, would you be so kind to reconsider the way you dealt your points in this question?
0
 
ozone7Author Commented:
????? Not Exactly Sure what you mean!!
0
 
Sjef BosmanGroupware ConsultantCommented:
How tragic. Forget it. Partha my bro, don't even think about donating points!
0
 
p_parthaCommented:
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
0
 
ozone7Author Commented:
Not sure how to do that.. Can you transfer points?? Tell me how!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 4
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now