Solved

Prompt user to save Text file in certain location

Posted on 2003-11-27
13
296 Views
Last Modified: 2013-12-18
Hi,

I have created an action button to pick some documents and write the contents into a Text file.
But how do I prompt the user to select the location to save the text file after I saved it in C:\?
I keeps getting OLE automation error at the line "Set myTxt = GetObject("C:\sampletxtfile.txt")".
Why?
Can someone enlighten me?
Thanks very much in advance!

Here is my scripts:
Dim sess As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim i As Integer, fileNum As Integer, fileName As String
Dim TxtFilePath As Variant, myTxt As Variant
      
Set db = sess.CurrentDatabase
Set dc = db.UnprocessedDocuments
      
If dc.Count = 0 Then
    Msgbox "Please select CCF forms before clicking this button!", 0+16, "Verification errors"
    Exit Sub
End If
      
fileNum = Freefile()
fileName = "C:\sampletxtfile.txt"
Open fileName For Output As fileNum

For i = 1 To dc.Count
   Set doc = dc.GetNthDocument(i)
   Write #fileNum, doc.P1(0), doc.T1(0), doc.DSO1(0), doc.DO1(0), doc.PS1(0), doc.PSG1(0), doc.RS1(0), doc.PO1(0), doc.POG1(0), _
   doc.RO1(0), doc.S1(0), doc.OI1(0), doc.CL(0)
Next

Close fileNum
Set myTxt = GetObject("C:\sampletxtfile.txt")
      
TxtFilePath = ws.OpenFileDialog(False, "Report 9 File Save as...", "", "c:", "sampletxtfile.txt")
If Not Isempty(TxtFilePath) Then
   Call myTxt.Saveas(TxtFilePath)
End If


kspuea
0
Comment
Question by:kspuea
  • 4
  • 4
  • 3
  • +1
13 Comments
 
LVL 19

Expert Comment

by:madheeswar
ID: 9835388
Dim files As Variant

files = workspace.OpenFileDialog(True, "File List", _
      "", "c:")


Is this what ur looking for?
0
 

Author Comment

by:kspuea
ID: 9836482
nope, not only that. I want to pick up the text file I generated previously and prompt the user to select a location to save it.
0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 9837236
You can not use a GetObject on a .TXT document. GetObject works only on Documents that are being served by an OLE server such as MS Word, MS Excel etc.

Just use OPEN statement to deal with .TXT documents.
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 31

Accepted Solution

by:
qwaletee earned 50 total points
ID: 9837667
Here's what your current logic is (even though it does not work):

1) Open a temporary text file
2) Gather data, and write text to file opened in step 1
3) Ask user where to save the file "permanently"
4) Save temporary file from steps 1 and 2 into new filename specified by user in step 3

This is what your logic should really be:
1) Ask user where to save file
2) Open file specified by user in step 1
3) Gather data, and write text to file opened in step 2

For step 1, use the ws.OpenFIleDialog method

Then use the file name returned by OpenFileDialog to do Open userSPecifiedFIleName for output as fileNum

That's it!
0
 

Author Comment

by:kspuea
ID: 9847228
Thanks very much, qwaletee!
It works wonderfully....  :-)
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 9847237
I think I gave solution first?

kspuea, bad idea not giving points to me.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9855144
madheeswar,
You only gave him the OpenFileDialog code suggestion.  He already had OpenFileDialog in the original question.  His problem was really one of structure and understanding how LotusScript file handling worked.
0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 9855210
Maddy, qwaletee's solution indeed was more comprensive. Yes you began, but qualetee did a good job afterwards. He has been awarded points for his clarity of explanation. This looks good.
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 9855217
OK. No problem.

I can understand it..

have a nice day
0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 9855224
Thanks Maddy, same to you.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 9856391
If you really want points, I'm perfectly willing to give them up.
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 9856429
Qwaletee,
What a change? R u kiding?

If I want points, I will ask u. As I said before, first I need to reach 3000 points. Until then I will have this type of mind and thinking.

Thanks for your offer anyway.

I think Ranjit will be willing to take.
What Ranjeet?

0
 
LVL 19

Expert Comment

by:RanjeetRain
ID: 9857211
Oh wow!!!! WOW WOW WOW!!!! Shall I prepone my bday? LOL ;-)
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question