Bad File Mode: Writing To Locked Binary .txt File

Oct 6, 2006

I have a .txt file created in Notepad and it contains a 4 digit number (Job ID). I am recieving the dreaded "Bad File Mode" (#54) error when writing back the file.

I would like to OPEN it as R/W locked, read it, increment it by 1 and write it back. Am perfectly willing to create the .txt as non-binary if that is causing the issue.

Dim jinChar As String
fileNumber = FreeFile()
jinFP = "JIN.txt"
Open jinFP For Binary Access Read Write Lock Read Write As #fileNumber
Input #fileNumber, jinChar
jobIDNumber = CInt(jinChar)
jobIDNumber = jobIDNumber + 1
jinChar = CStr(jobIDNumber)
Write #1, jinChar
Close #fileNumber

View 4 Replies


ADVERTISEMENT

Reading Binary File Bug

Jun 16, 2006

I am running into one of the strangest issues I have seen in a long time. I have a user defined type that I utilize in VB6 and write out to a binary file....

View 7 Replies View Related

How To Speed Up Binary File Read

Apr 9, 2014

I have written a little test sub which reads the contents of a binary file, which is approximately 0.2 Mb in size, into a byte array.

My sub is as follows:

[Code]...

It works just fine, BUT, it is incredibly slow (it spends 80 seconds in the For loop!!!!!)

How can I speed this up?

Note that the binary file can be of arbitrary size.

I tried using a string buffer filled with zeros, and it works!

View 1 Replies View Related

VBA - Open File NOT In Read Only Mode

Nov 27, 2011

I have a VBA script that has been running fine for months on one computer. Today, I ran it on another computer and it opened files in read only mode which disrupted everything.

The file open command is the following:

Workbooks.Open Filename:=sourcePath & sourceFileName

I searched the entire project and appended ", readonly:=false" to every open command. So, the command became

Workbooks.Open Filename:=sourcePath & sourceFileName, readonly:=false

Still, Excel opened the file in read only mode as seen in the title bar (filename [read-only]).

If I double-clicked on the file and opened it, it's NOT in read only mode. I checked the property of the file. It is NOT read only.

View 2 Replies View Related

Writing To Text File Without Quotations

Aug 6, 2014

This code I am using writes cell data to a text file starting from A1 and going down the column. Each line/row is written in quotes. How can I disable or replace the quotes with blanks in the text file?

Here is the code:

[Code] ........

View 2 Replies View Related

Writing Results To A Text File

Jun 12, 2009

I'm trying to do something very simple, but I haven't had any luck searching for a function in excel that will let me do it.

Column A is a list of directories on a server, i.e. 01april, 02april, etc.
Column B is the path to those main directories, i.e. /raid0/data/documents/april/
Column C is where users can can type "1" if they want the directory or leave it blank if they do not want it selected.
Column D, if the corresponding row in column C=1, will show the complete source path/filename based on Column A and Column B.
Column E, if the corresponding row in column C=1, will show the complete destination path/filename based on Column A and Column B.

This is all working fine.

What I want to be able to do now though, is somehow, when someone sends the document back to me, create an FTP queue. I can do this with BulletProof FTP, because it allows really simple text queues.

So, what I need excel to do is, when someone has finished selecting their files, is write the results to a text file like exactly like this (without the Line1:, etc.):

Line1: <text from D2>
Line2: 0
Line3: 0
Line4: 0
Line5: ?
Line6: <text from E2>

(then repeated for each row in the excel document until column A is returning blank)

Seems simple enough.. Any ideas?

Also, an extra question--> is there any way I can make Excel list a directory structure automatically? Could it display the file size for the entire directory? I don't necessarily want it to list every file, just the directory paths and size of each directory.

View 6 Replies View Related

Writing The Contents Of Cells Into A File

Apr 12, 2009

I have a bunch of values in column A, and I need to write (export) the entire column into a file called "ColumnA.dat".

create an Excel Macro Script that would accomplish that?

View 9 Replies View Related

Prevented From Writing To The .xlb File On Closing

Sep 15, 2009

I'm making a workbook which I want to distribute widely. It will have a lot of changes to the menus which happen 'onOpen'.

I am keen to not spoil peoples special menu setups on closing the workbook.

If I understand correctly, on closing, Excel writes the current menu settings to the .xlb file. Does anyone know of a way to prevent it doing this so that peoples setups are left unchanged?

Presumably there is code that will do it but I've searched a long time and found nothing.

View 9 Replies View Related

File Locked For Editing - How To Unlock

Mar 15, 2012

I am getting a message, the Excel file i am opening (xlsm) is locked for editing by 'another user'. But, NOT SO, of course; i am the only user logged in to this PC, and there is no network access. I quit Excel and verified that i see no Excel processes running. But, when i try to open the file, i still get the "locked by 'another user'" message, and at this point can only open read-only. I looked in the folder the file is in and do not see any of those ~ files or anything else suspicious.

So, what do i do? How do i "unlock"? How can i open this file once again to make modifications to it?

View 7 Replies View Related

2 Person Can Open File As Compatible Mode?

Jun 7, 2013

I have a file is used by many person at the same time. Sometime 2 person can open it as compatible mode , when 2nd person save will write over the 1st person data, that means all have been done by 1st person will be gone, serious problem.

Normally open a file will tell me who have using it , but it show wrongly person although the person has not open the file. worse that 1 day only show 1 person name.

View 4 Replies View Related

VBA Code Opens File In Compatibility Mode?

Jan 3, 2013

I have written a macro to loop through files and subfolders to open a specific file for a specific month. I extract the datasets for every excel file into a master template. The code works flawlessly when all of the files have the .xlsm extension. However, I need to open .xls file formats also. When my code opens the first .xls file, named "Staffing Plan.xls" it opens it and automatically makes it "Staffing Plan1 [Compatibility Mode]. I can't open the file in the original "Staffing Plan.xls" file format to read data from. How can I fix this?

View 3 Replies View Related

How To Change Line When Writing To Text File

Feb 9, 2012

Set FSO = New FileSystemObject
Set FSOFile = FSO.OpenTextFile(textfullname, 2, True)
FSOFile.Write ("xx")
FSOFile.Write ("02022012")
FSOFile.Writeline ("Next line")

I am getting this in the text file:- xx02022012Next line

I want this: xx02022012 Next line

How to change line when writing to a text file?? the writeline is not changing line.

View 1 Replies View Related

File Gets Locked By Users That Only Have Permission To Read

Feb 11, 2013

A user in our company has a document on a shared drive in our domain. It's using the protect feature which means that you'll have to type username/password before you're allowed to edit the document. The problem is that users who only want to view the document will cause it to lock, and then you can't edit it before they close it.

I thought that sharing the document would solve this issue, but when I tried to it said that Visual Basic features would not work which basically makes the document useless so that's not an option.

View 2 Replies View Related

Excel 2010 :: File Is Locked For Editing?

Jun 29, 2014

I tried to open excel file from shared drive but it's pop up

"File in use" xxxx.xls is locked for editing by XXXX, Open 'Read-Only' or click 'Notify' to open read-only and receive notification when the document is no longer in use.

I din't know how to insert the picture so that I wrote everything.

It happens almost every time even if file has not opened by any one. how can I stop it? Version: Excel 2010. OS Name: Microsoft windows 7 professional.

View 4 Replies View Related

File Locked For Editing By 'User Name' On Save

Mar 9, 2008

i have this code to run autofilter in protected sheet2, assigned to a check Box,
but it gives me this Msg when i run the code by checking the check Box: File in use.
The file is locked for editing by the (my name). However, when i excute the code by F5 in the VBE window, it works fine also when i excute the code from Worksheet_Activate , it works fine

Sub t()
With Sheet2
. Protect "0", , , , userinterfaceonly:=True, Allowautofilter:=True
.AutoFilterMode = False
.Range("A5:DT5").AutoFilter
End With
End Sub

View 2 Replies View Related

Can't Edit File That Opens In Protected View Mode

Apr 12, 2013

A client has sent me an Excel workbook that appears on the screen with the message adivising that it is Protected View as a result of having been downloaded from the internet. If I click on the Enable Editing button the workbook is completely deactivated. I have played around with my Trust Centre settings but nothing seems to work.

View 1 Replies View Related

Writing Batch File To Remove Spaces From Filenames

Oct 11, 2008

I realise this is not strictly an excel question but it forms part of my VBA code within excel

I have been writing a VBA program (with some fantastic help from you guys) part of which writes to a batch file to rename files stored in a given folder. Unfortunately this fails if the original files have spaces in the filenames. The batch file contains command lines such as: ...

View 6 Replies View Related

Master File To Control What Is Entered And When (locked Months When Not In Use)

Sep 7, 2007

i have this side project that i have been working on for the last few days around work... Excel based of course. to cut a long story short i have been working on a Master File (Team Leader)... this file controls around 15 other files (Team Members). from the Master File the Team Leader can lock / unlock worksheets for the Users (required) for the Team Leader this is displayed on a Listbox (Jan-Dec signifying 12 worksheets per person). Also the Team Leader File has two combobox's for "Team Member's Name" and "Type" then they see a large "commandbutton" that reads "Change Users Stats". the point of this is for the Team Leader... using their Master File to control what is entered and when (locked Months when not in use).

the User (Team Member 1 out of 15) then just enters their data within that given Month which is unlocked. so the Commandbutton checks for the Name Listed from Combobox1... then checks to see what Type from combobox2... then from the listbox checks to see which months need to be Locked or Unlocked. Additional: the "Type" indicates percentages from the Users File.

E.g. Type 1-3
type 1 = 100% in cell c5
type 1 = 50% in cell c6

etc etc...............

View 2 Replies View Related

Excel Form Writing Filled Data To Another File Or Sheet

Mar 5, 2014

Currently I work on a file which will be more like a form which will be filled by user and after he or she hits the button, the filled data will be written or sent to another Excel file or even Sheet in the same workbook which will store the filled data in database like form. The same as some web form which will post the data to database.

In other words, the workbook contains to sheets, one with forms to be filled in (cells) and one with specified columns. After filling in the cells on the first sheet and hitting the button, it will trigger the macro which will send data to second sheet and post data from each cell to appropriate column.

View 7 Replies View Related

Writing To File May Require Special Print Statement Syntax

Jan 22, 2013

Code:
' write data to txt file
For j = 1 To 3
For k = 1 To 21
Print FNum, OPTOarray(j, k)
Next k
Next j

I am writing an Array to a text file but I keep getting an error that the Print statement requires a suitable object. I tried Debug but all this did was put the data into the immediate window and created a file that was empty.

"????.Print FNum, OPTOarray(j, k)".

The data in the immediate window is correct but when you open the text file with notepad there is nothing to be seen.

View 1 Replies View Related

Save Excel File As Another File Using Current Date As Part Of File Name

Oct 10, 2011

VBA coding for automatically saving an excel file as another file using the current date as part of the file name together with "32ga" as a constant add-in. I also what this macro to run at a particular time of the day let say 00:20hrs. The excel file i want to save as is always open . It has data that changes every 24-hrs.

View 1 Replies View Related

Writing Specific Content From Excel To External File Of Specific Name

Apr 29, 2013

I have a worksheet that contains two basic columns of data, A and B. What I would like to do is based on the value in column A, I would like to copy the contents of column B to a textfile (preserving the basic line structure and hopefully without any extra characters like quotation marks attached). So for all the values in column A = 'Account', Id like to take all the corresponding values in Column E (for example) and save them to the same file, preferably where the filename itself as 'Account.xyz'. And I would like to do this for all unique values in Column A, that is do it for 'Account' and 'AccountPrivilege' etc. Note Column A is essentially presorted alphabetically already. There are actually 1000s of rows with hundreds of unique A values so Id like to find a way to automate this process.

A
B

1
Account
Company Information

2
Account
Company

[Code] ........

View 2 Replies View Related

Export Data From A Template File To Total List File Using Macro In Template File

Dec 18, 2012

I have a template file for ordering trafolyte and steel plates. I have added macros to this template file. The existing macros do the following (shortly described):

Macro 1: clears order
Macro 2: update order date + send a read only file to the supplier of plates + save a read only copy of the file into one of three folders acc to info in one of the cells.

It's the Macro 2 I want to edit.

I want to add a "function" which copy a selection of data.column A to N from row 12 to 548 but only the rows where there is a value in column A.

Row 1 to 11 includes standard order info and Macro buttons.
Row 11 includes the heading for order data.

For everytime someone click on the Macro 2 button in the template file, I want the selection to be paste into the first "available" row in a "Total list" file.

The "Total list" file may have to be open (or a function to open, paste selection and then close the "Total list" file may be added)

File and Folder info:

To simplify suggestions, the following file and path info can be used (I can change to the correct later):
Template file name: template_order.xlsm
Template file location: \servershared emplate

Total list file name: total_list.xlsx
Total list file location: \servershared otal

Selection info:

The template file exists of a "general order info area" A1:N10
The column heading for order data is located at A11:N11
The selection to be copied is A12:N550 - But only rows where column A includes data (not empty).
(If the spesific order consists of 14 plates than there will be item no 1-14 in column A and I then I want to copy A12:N25 (row 25 will be item 14).

When I try to use record macro it looks like it only records what's happening in the template file - It doesn't record the pasting in the total list.

View 1 Replies View Related

Open Website - Download CSV File / Save As In Specific Folder Under Different Name And File Type

Jul 6, 2012

I am trying to open a website, then for excel to download the csv file, then for it to save it in a specific folder under a specific name and file format (excel).

I am successful at opening the website with the following code, but how to do the rest.

Sub Searchez()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "http://quote.morningstar.ca/Quicktakes/stock/keyratios.aspx?t=clwr®ion=USA&culture=en-CA&ops=clear" 'load web page google.com
IE.Visible = True
While IE.Busy
DoEvents
Wend

'IE.Navigate2 "javascript:SRT_keystuts.exportcsv()"
'this is the name of the download link as from when i hover my pointer over download link.
End Sub

View 1 Replies View Related

Opening Excel File From List Of File Names Located In Single Sheet?

May 31, 2013

loop and range function to apply in the below code through which I can avoid writing code for all the rows.

I am trying to open excel files located in single folder from files name (along with the path) in single worksheet (Column B and Row 1 to 500).

I have created follwing code which opens the file and then runs a macro in it.

a Sub Test()
Dim strFName As String
strFName = Sheet1.Range("B2").Value

[Code].....

View 4 Replies View Related

Date Function- Open A File, Make An Exact Copy And Save It Under A New File Name

Jun 4, 2009

I'm working on the following
Workbooks.Open Filename:= _
"D:CommondataIBMmainBRANCHBURG-PRODUCTS-BOM-ALUMINUM-UPDATE-" & Ucase(Format(DateAdd("y", 0, Date)), "YYYY-MM-DD")&".XLS"
ChDir "D:CommondataIBMmain"
ActiveWorkbook.SaveAs Filename:= _
"D:CommondataIBMmainBRANCHBURG-PRODUCTS-BOM-ALUMINUM-UPDATE-NAFTA.XLS", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
ActiveWindow.Close

Date: 2009-06-03

What I'm trying too do is open a file, make an exact copy and save it under a new file name.

My problem is in the date formula the day is not always the same. In the sample case it's 03 at other times the day will change.

is there a way too get this too work irregardles of what the day might be?

View 9 Replies View Related

Extract Data And File Names From File In Folder And Paste Into One Sheet?

Jan 13, 2013

The code below looks at file names in column A and then goes to a folder and opens and copies the data in range c2 -lastrow from each file and pastes the data into sheet2.

how I could add to the code so that it also inserts the file name in column c?

It would make it easier to track the data in column B.

VB:
Sub CopyFromFile()
Dim fPath As String
Dim lRow As Long

[Code].....

I have attached a sample workbook. The list of file name is in sheet 1. An example of the output is in sheet 2. The data in column A is dummy data generally spans 100's of rows not just 10 as in the example.

The purpose of the code is to be able to put a list of file names in column a in sheet 1 and extract data from those files in a folder. The data extraction works fine. The reson for adding the file names is so that I know what file the data came from.

View 1 Replies View Related

Macro To Download Csv File From A Dynamic Date Based Url To A File Location

Feb 23, 2014

I have a requirement to download a lot of historical data files from the archieve of an website. The url goes something like this: [URL]....

This downloads file for 21022014 ie. 21-Feb-2014. I need to be able to have a facility to have a selection criteria on my user form (in excel) where I specify a date range and the macro automatically downloads all the valid excel files available within that date range (files for Saturday, Sunday and some holiday dates will not be available in the website archive database) one after the other (like at single clcik of button) into a specific location (predefined viz.. c:/Users/EOD files/) on my laptop. Best would be if I am able to select the save location run time by using a 'Browse' like feature where I go and choose my local laptop folder...same type when we try uploading a file from our laptop to the web..

View 1 Replies View Related

Automatically Open File In Specific File Path When Another Sheet Is Opened

Mar 20, 2014

I want to open a specific sheet and refresh only said sheet when i open another sheet for example x.xls

So opening x.xls will automatically open y.xls

I've tried this in the workbook code area but it doesn't do anything.

[Code] .....

View 1 Replies View Related

External File(s) Referenced And File Links Change Based On Row Cell

Oct 22, 2009

I have attached the file I am working on. I am attempting to create a link to an external file based on the value of cells in column A. Then I would like to simply copy the formula down, lets say in Column B, the rows and as I do the external file reference will change depending on the value within the cell in Column A. I hope that I am making sense.

I am using Windows Vista with Excel 2007. The files will all be within the same file folder, however, there are hundereds of files so I won't be able to open them all for the indirect to work.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved