 |
|
|
|
| Author |
Message |
bbnimda
Joined: 13 Aug 2007 Posts: 46
|
Posted: Wed Feb 13, 2008 8:32 pm Post subject: Outlook Script: How to create / delete txt file |
|
|
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 |
|
 |
Eric Legault [MVP - Outlo
Joined: 12 Aug 2007 Posts: 60
|
Posted: Wed Feb 13, 2008 6:28 pm Post subject: RE: Outlook Script: How to create / delete txt file |
|
|
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 |
|
 |
bbnimda
Joined: 13 Aug 2007 Posts: 46
|
Posted: Thu Feb 14, 2008 3:17 pm Post subject: Re: Outlook Script: How to create / delete txt file |
|
|
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 |
|
 |
Eric Legault [MVP - Outlo
Joined: 12 Aug 2007 Posts: 60
|
Posted: Thu Feb 14, 2008 12:23 pm Post subject: Re: Outlook Script: How to create / delete txt file |
|
|
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 |
|
 |
bbnimda
Joined: 13 Aug 2007 Posts: 46
|
Posted: Thu Feb 14, 2008 9:57 pm Post subject: Re: Outlook Script: How to create / delete txt file |
|
|
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 |
|
 |
Eric Legault [MVP - Outlo
Joined: 12 Aug 2007 Posts: 60
|
Posted: Thu Feb 14, 2008 1:12 pm Post subject: Re: Outlook Script: How to create / delete txt file |
|
|
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 |
|
 |
bbnimda
Joined: 13 Aug 2007 Posts: 46
|
Posted: Fri Feb 15, 2008 7:08 pm Post subject: Re: Outlook Script: How to create / delete txt file |
|
|
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 |
|
 |
|
|
| 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. |
|
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
|