Wrox Programmer Forums
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 16th, 2007, 06:43 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default Save file as Read-Only

Hi,

I've created a '.csv' file using the stripped down VBA method below:

(File is strCSVFiles)

Code:
Dim intFileNum As Integer

On Error Resume Next
Close #intFileNum
intFileNum = FreeFile()
On Error GoTo 0

strLine = ""
Open strCSVFiles For Output As #intFileNum

On Error GoTo Leave_Sub
i = 1
Do While Len(Trim(.Cells(i, 1))) <> 0

    strLine = strLine & blah,blah,blah

    Print #intFileNum, Mid(strLine, 1)
    strLine = Empty
    i = i + 1
Loop
Close #intFileNum
[u]Question</u>
Is it also possible to save the same '.csv' file as read-only using VBA?

Thanks in advance,


Neal

A Northern Soul
__________________
Neal

A Northern Soul
 
Old May 16th, 2007, 08:35 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Just include the following:

SetAttr "c:\sample.csv", vbReadOnly

It should work

Cheers
Shasur

http://www.vbadud.blogspot.com
 
Old May 17th, 2007, 03:35 AM
Friend of Wrox
 
Join Date: Jan 2006
Posts: 131
Thanks: 10
Thanked 0 Times in 0 Posts
Default

Thanks Shasur,

I appreciate your help. Looks to be working fine.

Neal

A Northern Soul





Similar Threads
Thread Thread Starter Forum Replies Last Post
Read CSV file - Save Columns into Rows pintoo BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 1 August 20th, 2008 09:01 AM
Save PDF file as text file in VB.Net kvenkatu Classic ASP Basics 0 April 7th, 2006 01:09 PM
save a PDF file as text file through VB. NET kvenkatu VB.NET 0 April 6th, 2006 12:15 PM
How to Read,Write, & Save (File Processing) ck C++ Programming 2 April 18th, 2005 07:28 AM
How to Read,Write, & Save (File Processing) ck Visual C++ 1 January 23rd, 2005 02:16 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.