msoutlook.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Outlook Script: How to create / delete txt file

 
Post new topic   Reply to topic    msoutlook.org Forum Index -> Outlook Program Forms
Author Message
bbnimda



Joined: 13 Aug 2007
Posts: 46

PostPosted: Wed Feb 13, 2008 8:32 pm    Post subject: Outlook Script: How to create / delete txt file Reply with quote

Hi all,

I use custom form and I want to know how to manipulate simple file *.txt

I need 3 operations
1) check if xxx.txt exist
2) delete xxx.txt
3) save the content of listbox to xxx.txt

2nd step
load the content of xxx.txt to a listbox


tks
--

Archived from group: microsoft>public>outlook>program_forms
Back to top
View user's profile Send private message
Eric Legault [MVP - Outlo



Joined: 12 Aug 2007
Posts: 60

PostPosted: Wed Feb 13, 2008 6:28 pm    Post subject: RE: Outlook Script: How to create / delete txt file Reply with quote

You can use the VBA.FileSystem.Dir function to check for the existence of a
file and VBA.FileSystem.Kill to delete files.

Here's a sample for reading from a file:

Dim MyChar
Open "TESTFILE" For Input As #1 ' Open file for reading.
Do While Not EOF(1) ' Loop until end of file.
MyChar = Input(1, #1) ' Read next character of data.
Debug.Print Seek(1) ' Print byte position to the
' Immediate window.
Loop
Close #1 ' Close file.

The Microsoft Scripting Library has a FileSystemObject class that can also
be used for file operations.

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"bbnimda" wrote:

> Hi all,
>
> I use custom form and I want to know how to manipulate simple file *.txt
>
> I need 3 operations
> 1) check if xxx.txt exist
> 2) delete xxx.txt
> 3) save the content of listbox to xxx.txt
>
> 2nd step
> load the content of xxx.txt to a listbox
>
>
> tks
> --
>
>
>
Back to top
View user's profile Send private message
bbnimda



Joined: 13 Aug 2007
Posts: 46

PostPosted: Thu Feb 14, 2008 3:17 pm    Post subject: Re: Outlook Script: How to create / delete txt file Reply with quote

It doesnt work

but I tryed FileSystemObject and found the way to Check if file exist
and delete it

here is my code
Set objFSO = CreateObject("Scripting.FileSystemObject")
if objfso.FileExists("C:\FSO\FileT.txt") then
objfso.DeleteFile "C:\FSO\FileT.txt"
else
.....
.....
.....
end if

But I still looking for a way to Create a new file and fill it and Save
it



"Eric Legault [MVP - Outlook]" a écrit dans
le message de news: 39080FB7-1BA7-46EE-91C1-1CCD96D3B87F@microsoft.com...
> You can use the VBA.FileSystem.Dir function to check for the existence of
> a
> file and VBA.FileSystem.Kill to delete files.
>
> Here's a sample for reading from a file:
>
> Dim MyChar
> Open "TESTFILE" For Input As #1 ' Open file for reading.
> Do While Not EOF(1) ' Loop until end of file.
> MyChar = Input(1, #1) ' Read next character of data.
> Debug.Print Seek(1) ' Print byte position to the
> ' Immediate window.
> Loop
> Close #1 ' Close file.
>
> The Microsoft Scripting Library has a FileSystemObject class that can also
> be used for file operations.
>
> --
> Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
> Try Picture Attachments Wizard for Outlook:
> http://www.collaborativeinnovations.ca
> Blog: http://blogs.officezealot.com/legault/
>
>
> "bbnimda" wrote:
>
>> Hi all,
>>
>> I use custom form and I want to know how to manipulate simple file
>> *.txt
>>
>> I need 3 operations
>> 1) check if xxx.txt exist
>> 2) delete xxx.txt
>> 3) save the content of listbox to xxx.txt
>>
>> 2nd step
>> load the content of xxx.txt to a listbox
>>
>>
>> tks
>> --
>>
>>
>>
Back to top
View user's profile Send private message
Eric Legault [MVP - Outlo



Joined: 12 Aug 2007
Posts: 60

PostPosted: Thu Feb 14, 2008 12:23 pm    Post subject: Re: Outlook Script: How to create / delete txt file Reply with quote

Did you change "TESTFILE" to a valid file path?

You can also create a file with the FileSystemObject:

Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile= fso.CreateTextFile("c:\testfile.txt", True)
MyFile.WriteLine("This is a test.")
MyFile.Close

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"bbnimda" wrote:

> It doesnt work
>
> but I tryed FileSystemObject and found the way to Check if file exist
> and delete it
>
> here is my code
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> if objfso.FileExists("C:\FSO\FileT.txt") then
> objfso.DeleteFile "C:\FSO\FileT.txt"
> else
> .....
> .....
> .....
> end if
>
> But I still looking for a way to Create a new file and fill it and Save
> it
>
>
>
> "Eric Legault [MVP - Outlook]" a écrit dans
> le message de news: 39080FB7-1BA7-46EE-91C1-1CCD96D3B87F@microsoft.com...
> > You can use the VBA.FileSystem.Dir function to check for the existence of
> > a
> > file and VBA.FileSystem.Kill to delete files.
> >
> > Here's a sample for reading from a file:
> >
> > Dim MyChar
> > Open "TESTFILE" For Input As #1 ' Open file for reading.
> > Do While Not EOF(1) ' Loop until end of file.
> > MyChar = Input(1, #1) ' Read next character of data.
> > Debug.Print Seek(1) ' Print byte position to the
> > ' Immediate window.
> > Loop
> > Close #1 ' Close file.
> >
> > The Microsoft Scripting Library has a FileSystemObject class that can also
> > be used for file operations.
> >
> > --
> > Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
> > Try Picture Attachments Wizard for Outlook:
> > http://www.collaborativeinnovations.ca
> > Blog: http://blogs.officezealot.com/legault/
> >
> >
> > "bbnimda" wrote:
> >
> >> Hi all,
> >>
> >> I use custom form and I want to know how to manipulate simple file
> >> *.txt
> >>
> >> I need 3 operations
> >> 1) check if xxx.txt exist
> >> 2) delete xxx.txt
> >> 3) save the content of listbox to xxx.txt
> >>
> >> 2nd step
> >> load the content of xxx.txt to a listbox
> >>
> >>
> >> tks
> >> --
> >>
> >>
> >>
>
>
>
Back to top
View user's profile Send private message
bbnimda



Joined: 13 Aug 2007
Posts: 46

PostPosted: Thu Feb 14, 2008 9:57 pm    Post subject: Re: Outlook Script: How to create / delete txt file Reply with quote

Yes I all ready found "CreateTextFile" but still was looking for the way
to fill the file ( tks for Writeline )

Ok now I know how to create , fill and save a text file

Now I have to open an existing text file and get data from this file

Tks for help




"Eric Legault [MVP - Outlook]" a écrit dans
le message de news: 83C9CCF0-C79C-4D21-8DDC-50BF25A7BF66@microsoft.com...
> Did you change "TESTFILE" to a valid file path?
>
> You can also create a file with the FileSystemObject:
>
> Dim fso, MyFile
> Set fso = CreateObject("Scripting.FileSystemObject")
> Set MyFile= fso.CreateTextFile("c:\testfile.txt", True)
> MyFile.WriteLine("This is a test.")
> MyFile.Close
>
> --
> Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
> Try Picture Attachments Wizard for Outlook:
> http://www.collaborativeinnovations.ca
> Blog: http://blogs.officezealot.com/legault/
>
>
> "bbnimda" wrote:
>
>> It doesnt work
>>
>> but I tryed FileSystemObject and found the way to Check if file exist
>> and delete it
>>
>> here is my code
>> Set objFSO = CreateObject("Scripting.FileSystemObject")
>> if objfso.FileExists("C:\FSO\FileT.txt") then
>> objfso.DeleteFile "C:\FSO\FileT.txt"
>> else
>> .....
>> .....
>> .....
>> end if
>>
>> But I still looking for a way to Create a new file and fill it and
>> Save
>> it
>>
>>
>>
>> "Eric Legault [MVP - Outlook]" a écrit
>> dans
>> le message de news: 39080FB7-1BA7-46EE-91C1-1CCD96D3B87F@microsoft.com...
>> > You can use the VBA.FileSystem.Dir function to check for the existence
>> > of
>> > a
>> > file and VBA.FileSystem.Kill to delete files.
>> >
>> > Here's a sample for reading from a file:
>> >
>> > Dim MyChar
>> > Open "TESTFILE" For Input As #1 ' Open file for reading.
>> > Do While Not EOF(1) ' Loop until end of file.
>> > MyChar = Input(1, #1) ' Read next character of data.
>> > Debug.Print Seek(1) ' Print byte position to the
>> > ' Immediate window.
>> > Loop
>> > Close #1 ' Close file.
>> >
>> > The Microsoft Scripting Library has a FileSystemObject class that can
>> > also
>> > be used for file operations.
>> >
>> > --
>> > Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
>> > Try Picture Attachments Wizard for Outlook:
>> > http://www.collaborativeinnovations.ca
>> > Blog: http://blogs.officezealot.com/legault/
>> >
>> >
>> > "bbnimda" wrote:
>> >
>> >> Hi all,
>> >>
>> >> I use custom form and I want to know how to manipulate simple file
>> >> *.txt
>> >>
>> >> I need 3 operations
>> >> 1) check if xxx.txt exist
>> >> 2) delete xxx.txt
>> >> 3) save the content of listbox to xxx.txt
>> >>
>> >> 2nd step
>> >> load the content of xxx.txt to a listbox
>> >>
>> >>
>> >> tks
>> >> --
>> >>
>> >>
>> >>
>>
>>
>>
Back to top
View user's profile Send private message
Eric Legault [MVP - Outlo



Joined: 12 Aug 2007
Posts: 60

PostPosted: Thu Feb 14, 2008 1:12 pm    Post subject: Re: Outlook Script: How to create / delete txt file Reply with quote

This might come in handy:

VBScript Language Reference:
http://msdn2.microsoft.com/en-us/library/d1wf56tt.aspx

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"bbnimda" wrote:

> Yes I all ready found "CreateTextFile" but still was looking for the way
> to fill the file ( tks for Writeline )
>
> Ok now I know how to create , fill and save a text file
>
> Now I have to open an existing text file and get data from this file
>
> Tks for help
>
>
>
>
> "Eric Legault [MVP - Outlook]" a écrit dans
> le message de news: 83C9CCF0-C79C-4D21-8DDC-50BF25A7BF66@microsoft.com...
> > Did you change "TESTFILE" to a valid file path?
> >
> > You can also create a file with the FileSystemObject:
> >
> > Dim fso, MyFile
> > Set fso = CreateObject("Scripting.FileSystemObject")
> > Set MyFile= fso.CreateTextFile("c:\testfile.txt", True)
> > MyFile.WriteLine("This is a test.")
> > MyFile.Close
> >
> > --
> > Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
> > Try Picture Attachments Wizard for Outlook:
> > http://www.collaborativeinnovations.ca
> > Blog: http://blogs.officezealot.com/legault/
> >
> >
> > "bbnimda" wrote:
> >
> >> It doesnt work
> >>
> >> but I tryed FileSystemObject and found the way to Check if file exist
> >> and delete it
> >>
> >> here is my code
> >> Set objFSO = CreateObject("Scripting.FileSystemObject")
> >> if objfso.FileExists("C:\FSO\FileT.txt") then
> >> objfso.DeleteFile "C:\FSO\FileT.txt"
> >> else
> >> .....
> >> .....
> >> .....
> >> end if
> >>
> >> But I still looking for a way to Create a new file and fill it and
> >> Save
> >> it
> >>
> >>
> >>
> >> "Eric Legault [MVP - Outlook]" a écrit
> >> dans
> >> le message de news: 39080FB7-1BA7-46EE-91C1-1CCD96D3B87F@microsoft.com...
> >> > You can use the VBA.FileSystem.Dir function to check for the existence
> >> > of
> >> > a
> >> > file and VBA.FileSystem.Kill to delete files.
> >> >
> >> > Here's a sample for reading from a file:
> >> >
> >> > Dim MyChar
> >> > Open "TESTFILE" For Input As #1 ' Open file for reading.
> >> > Do While Not EOF(1) ' Loop until end of file.
> >> > MyChar = Input(1, #1) ' Read next character of data.
> >> > Debug.Print Seek(1) ' Print byte position to the
> >> > ' Immediate window.
> >> > Loop
> >> > Close #1 ' Close file.
> >> >
> >> > The Microsoft Scripting Library has a FileSystemObject class that can
> >> > also
> >> > be used for file operations.
> >> >
> >> > --
> >> > Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
> >> > Try Picture Attachments Wizard for Outlook:
> >> > http://www.collaborativeinnovations.ca
> >> > Blog: http://blogs.officezealot.com/legault/
> >> >
> >> >
> >> > "bbnimda" wrote:
> >> >
> >> >> Hi all,
> >> >>
> >> >> I use custom form and I want to know how to manipulate simple file
> >> >> *.txt
> >> >>
> >> >> I need 3 operations
> >> >> 1) check if xxx.txt exist
> >> >> 2) delete xxx.txt
> >> >> 3) save the content of listbox to xxx.txt
> >> >>
> >> >> 2nd step
> >> >> load the content of xxx.txt to a listbox
> >> >>
> >> >>
> >> >> tks
> >> >> --
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>
>
Back to top
View user's profile Send private message
bbnimda



Joined: 13 Aug 2007
Posts: 46

PostPosted: Fri Feb 15, 2008 7:08 pm    Post subject: Re: Outlook Script: How to create / delete txt file Reply with quote

Tks a lot Eric,

Now my form is working perfectly

Bye

"Eric Legault [MVP - Outlook]" a écrit dans
le message de news: EEC21795-E667-4AA7-9461-5FC75C4F5837@microsoft.com...
> This might come in handy:
>
> VBScript Language Reference:
> http://msdn2.microsoft.com/en-us/library/d1wf56tt.aspx
>
> --
> Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
> Try Picture Attachments Wizard for Outlook:
> http://www.collaborativeinnovations.ca
> Blog: http://blogs.officezealot.com/legault/
>
>
> "bbnimda" wrote:
>
>> Yes I all ready found "CreateTextFile" but still was looking for the
>> way
>> to fill the file ( tks for Writeline )
>>
>> Ok now I know how to create , fill and save a text file
>>
>> Now I have to open an existing text file and get data from this file
>>
>> Tks for help
>>
>>
>>
>>
>> "Eric Legault [MVP - Outlook]" a écrit
>> dans
>> le message de news: 83C9CCF0-C79C-4D21-8DDC-50BF25A7BF66@microsoft.com...
>> > Did you change "TESTFILE" to a valid file path?
>> >
>> > You can also create a file with the FileSystemObject:
>> >
>> > Dim fso, MyFile
>> > Set fso = CreateObject("Scripting.FileSystemObject")
>> > Set MyFile= fso.CreateTextFile("c:\testfile.txt", True)
>> > MyFile.WriteLine("This is a test.")
>> > MyFile.Close
>> >
>> > --
>> > Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
>> > Try Picture Attachments Wizard for Outlook:
>> > http://www.collaborativeinnovations.ca
>> > Blog: http://blogs.officezealot.com/legault/
>> >
>> >
>> > "bbnimda" wrote:
>> >
>> >> It doesnt work
>> >>
>> >> but I tryed FileSystemObject and found the way to Check if file
>> >> exist
>> >> and delete it
>> >>
>> >> here is my code
>> >> Set objFSO = CreateObject("Scripting.FileSystemObject")
>> >> if objfso.FileExists("C:\FSO\FileT.txt") then
>> >> objfso.DeleteFile "C:\FSO\FileT.txt"
>> >> else
>> >> .....
>> >> .....
>> >> .....
>> >> end if
>> >>
>> >> But I still looking for a way to Create a new file and fill it and
>> >> Save
>> >> it
>> >>
>> >>
>> >>
>> >> "Eric Legault [MVP - Outlook]" a écrit
>> >> dans
>> >> le message de news:
>> >> 39080FB7-1BA7-46EE-91C1-1CCD96D3B87F@microsoft.com...
>> >> > You can use the VBA.FileSystem.Dir function to check for the
>> >> > existence
>> >> > of
>> >> > a
>> >> > file and VBA.FileSystem.Kill to delete files.
>> >> >
>> >> > Here's a sample for reading from a file:
>> >> >
>> >> > Dim MyChar
>> >> > Open "TESTFILE" For Input As #1 ' Open file for reading.
>> >> > Do While Not EOF(1) ' Loop until end of file.
>> >> > MyChar = Input(1, #1) ' Read next character of data.
>> >> > Debug.Print Seek(1) ' Print byte position to the
>> >> > ' Immediate window.
>> >> > Loop
>> >> > Close #1 ' Close file.
>> >> >
>> >> > The Microsoft Scripting Library has a FileSystemObject class that
>> >> > can
>> >> > also
>> >> > be used for file operations.
>> >> >
>> >> > --
>> >> > Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming,
>> >> > etc.)
>> >> > Try Picture Attachments Wizard for Outlook:
>> >> > http://www.collaborativeinnovations.ca
>> >> > Blog: http://blogs.officezealot.com/legault/
>> >> >
>> >> >
>> >> > "bbnimda" wrote:
>> >> >
>> >> >> Hi all,
>> >> >>
>> >> >> I use custom form and I want to know how to manipulate simple file
>> >> >> *.txt
>> >> >>
>> >> >> I need 3 operations
>> >> >> 1) check if xxx.txt exist
>> >> >> 2) delete xxx.txt
>> >> >> 3) save the content of listbox to xxx.txt
>> >> >>
>> >> >> 2nd step
>> >> >> load the content of xxx.txt to a listbox
>> >> >>
>> >> >>
>> >> >> tks
>> >> >> --
>> >> >>
>> >> >>
>> >> >>
>> >>
>> >>
>> >>
>>
>>
>>

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Outlook script for forms We have written vbscript for Outlook 97 forms, then upgraded to 2003. Everything worked ok. Now we upgraded to Office 2007. The vbscript for the forms do not respond. We have these form in Public folders. I can get the script to work either in my pers

Outlook Script: How to know if a contact is opened by some o My config: Sbs & outlook 2k3 Hi all, Is there a way to know if a contact item (in public folder) is opened or not ( using a builtin properties or some thing else ) Tks --

Outlook Script: Pb closing Excel Hi All, I use an outlook script, I create/open an excel file and write/get info from/to the Excell File, All is working fine But when I check the task manager, Excel remain in the process list How can I stop it correctly. here's a part of my code Set objE

Outlook Script: Problem using Find Hi All and happy New Year, Specially to U Sue (Good Health and Lot of money ;) ) My Config: Outllook 2003 and Sbs 2003 I use a personal Form, and Before Saving a new Contact I check if it doesn't exist Yet So I perform a check using the company Name All

Outlook Script:How to extract the name of fields used in a f Hi all, Is there a way to know (using outlook script) all the << fields >> used in a Form (builtin and custom) tks -- Knowlege grows when shared.
Post new topic   Reply to topic    msoutlook.org Forum Index -> Outlook Program Forms All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group