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


ADVERTISEMENT

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 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

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

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

Closing Excel File Using VB

Apr 19, 2014

At the moment, there is no compile error or runtime error, but if I manually attempt to open the file (that was successfully read from), I get the message that the file is already open and is locked by myself (the user) and that multiple Excel processes are still running (I checked the task manager).

How do I close this Excel file (no changes to be made since I only read from the file) and quit Excel from running ?

Here is what I have at the moment :

Dim FirstName, Surname As String
'file path and name for the Excel file
Dim FileNamePath As String = "C:UsersMRCDesktopMRC FilesVisual Basic FilesSwimManager 2014CurrentSeasonDATASquadData.xls"

[Code].....

View 4 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

Closing A File Opened Via GetOpenFilename

Oct 6, 2009

The Macro asks the user to point at the location of a report, it then copies information out of that report and pastes it into a master sheet. The part I am having trouble with is closing the file that data has been copied from.

I have tried different things to close it such as

View 2 Replies View Related

Auto Save When Closing File

Feb 16, 2004

I close an existing excel file I need to automatically save it to another folder as the same name. I don't want any prompts or save as boxes to appear when this happens.

I need to do this as I use the file all the time, but need to save it on to a network where others can view it.

View 9 Replies View Related

How To Fix Column Width And Save It Before Closing File

May 30, 2002

I am trying to fix the width of a column everytime I open it but I can't. After I have fixed the column width and saved it before I close the file, when i reopen it, the column width will expand. The data source of that column is a real time query. I tried to lock the cell but when i locked it, I can't refresh the data from the query as it is locked. So, is there any way for me to achieve that?

View 4 Replies View Related

Stop File Closing If Ranges Blank

Nov 14, 2006

I have workbook that has questions on column K and L that NEED to be answered. When the user closes the spreadsheet I need the macro to create a pop up that says "unfinished Workbook"

So I need a macro that tells the user to finish answering the questions on K and L -

View 5 Replies View Related

Closing Txt File Thru' Vba Without Save Changes Dialog Box Appearing

Jan 31, 2007

I want to close a tab delimited Txt file that is open in Excel, thru' a macro, without the save changes dialog box appearing.

View 2 Replies View Related

Closing And Re-opening The Same File In Excel On-click Method

Oct 15, 2008

I was wondering if there is any code using an on-click method. When clicking a button i need excel to exit the file/sheet without saving (no prompts) and then re-open the exact same file/sheet once it has closed.

In a way this is like a refresh button.

View 14 Replies View Related

VBA - Syntax Delete Data From Clipboard Before Closing A File

Feb 22, 2008

I recorded a Macro to open a workbook, copy and paste data from one excel workbook to another, and close the workbook which was opened. Everything works fine except:

because of the amount of data that I am copying, I get a message box saying "There is a large amount of information on the Clipboard. Do you want to be able to paste this information into another prgoram later?" with a Yes/No button.

So now I have to click the "No" button before my macro closes the excel file. Is there a simple line of code that will by-pass this?

I am assuming it has to do with the following:

Windows("Book1.xls").Activate
ActiveWindow.Close , savechanges:=False

View 5 Replies View Related

Excel - Delete Unwanted Rows On Closing File

Dec 30, 2011

I want to delete some unwanted rows on closing my excel file. the blank rows are between set of datas. so it has to check all the blank rows, delete it until the last one. example

data
blank rows
data
blank rows
data
blank rows
data

View 4 Replies View Related

Excel 2010 :: Hiding Worksheets When Closing File?

Apr 28, 2012

I am using MS Excel 2010.

What I want to Hide two worksheets and leave one worksheet open when I close out the file.

ws TOC will remain open when closing out the file
ws Rqmts will hide when closing out the file
ws Planning will hide when closing out the file

View 1 Replies View Related

Reduce Number Of Times Opening And Closing Blank Source File

Jul 9, 2012

I have code in VBA that takes a source Excel file and parses it to multiple re-formatted worksheets. Each formatted worksheet is different depending on a variable in the source. There are n of each type of data (1:n Water Sources, 1:n Water Treatment, 1:n Water Storage). Each item needs a copy of a blank re-formatted worksheet appended to the end of the existing data-type worksheet. For example: Water Source #2 is appended to the bottom of Water Source #1 on the same worksheet.

Currently, I am opening the blank re-formatted workbook each time an additional variable of same type is found in the source file. Meaning, if there are 8 Water Sources, I am opening and closing the blank re-formatted workbook 7 times to copy a blank Water Source to the bottom of the Water Source worksheet and then populate the data. AND if there are 3 Water Treatment, I would open and close the blank formatted workbook 2 more times to copy a blank Water Treatment to the bottom of the Water Treatment worksheet. The same goes for Water Treatment.

Obviously, a huge waste of resources and performance. I would rather open the blank re-formatted workbook once (first time an additional worksheet is needed), use the worksheets as needed, and close it at the end.

Attached is my current, working code of the above.

How should I re-write it to check if the blank workbook is already open use it, if not open it?

Code:
Sub Add_Facility(ByVal Worksheet_Name, Copy_Range, Max_Limit)
Dim Last_Row As Integer
Dim Source_Range As Range
Dim Dest_Range As Range
Dim wkb As Workbook

Set wkb = ActiveWorkbook

[Code] ........

View 5 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

Closing Workbook When Closing Userform

Sep 14, 2006

I have a userform which opens when the workbook opens. Ideally Id like to have the userform open without the workbook coming up and have the workbook close when you close the userform. If thats not doable then is there a way to just close the workbook when the userform is closed?

View 3 Replies View Related

Writing Value 0 In Different Ranges?

Nov 13, 2012

I have a table in which some of the ranges have to be set to "0" (write "0" inside, not delete) when I click on a button. All the other cells expect these ranges are locked. For now I use the very long way, with the following VBA Code:

Range("E7").Select
ActiveCell.FormulaR1C1 = "0"
Selection.AutoFill Destination:=Range("E7:E21"), Type:=xlFillValues

[Code]....

There are more columns for which I have to do that, and it goes until row 500+ .. I used "Register Macro" to find out this code, that's why I guess it's obselete.

Is there any way I can do it, at least write all the ranges I have to fill with "0" next to each other instead of every time selecting, then inserting 0, then autofill the rang with...?

View 9 Replies View Related

Writing A Between Statement

Dec 15, 2006

I have a list of items in a pivot table where each item has a date. I want to see how many items occur for each month. I am trying to use the COUNTIF formula, but I'm having trouble figuring out how to write the criteria for the dates.

How do I write the criteria part to include the entire month?

View 9 Replies View Related

Writing Macro

Jul 3, 2007

i have an report in which i need to delete the entire row if the column contains values more than 250K, but the chanllenge here is; if any of the cells in the column contains a formula then the macro should not delete the row.....

View 9 Replies View Related

Writing To Word

Sep 25, 2008

if I have another instance of word open my macro will not work correctly. I am at a loss on how to figure this out. Also some times I get the error of virtual machine is not available when getting activedocument.name.

Sub TestTemp()
Application.ScreenUpdating = False

Dim bname as string

bname = Range("B6").Value

Dim WdApp As Object, WdDoc As Object
Set WdApp = CreateObject("Word.Application")
WdApp.Documents.Add "C:TemplatesTest Letter1.dot"
Application.Visible = True
WdApp.Visible = True

AModDoc = ActiveDocument.Name

Documents(AModDoc).Bookmarks("Line1").Range.InsertBefore bname

Application.ScreenUpdating = True
End Sub

View 9 Replies View Related

Writing Subroutine

Oct 27, 2008

in writing a subroutine that needs to ask the user

1) tax file number
2) Income
3) tax withheld

It then needs to use a function that i already made called 'incometax' that calculates 'taxpayable' and use that to calculate taxreturn (difference between 'taxpayable' and 'taxwithheld').

I then need it to output like this in a message box

Estimate for tax file number: .....
Created on ......
Total income: ......
Tax witheld: .......
Tax payable: ......Tax return: .......

View 9 Replies View Related

SelectCase Not Writing Value

Nov 15, 2008

The following code is supposed to write values from one file into another file - depending on the value of Current_Rider_Name. However, although the code runs and values are being picked up (this is checked through the line that is being commented out).

However nothing is being written to the file. Can anybody point me in the right direction? ...

View 9 Replies View Related

Writing An IRR Function In VBA

Aug 16, 2009

way to write your own IRR function using VBA.

Say if I call it Function MYIRR(cfs,per). Where cashflows occur in the periods specified..
i.e
Periods: 0 1 3 4 6
Cashflows: -1000 300 500 100 200

I'm having trouble making sure the initial cash outlay and then cash inflows assumptions hold (problem with the -/+ sign).

I've been told by a friend to try and use abs() function, 'For..Next' loop construct inside a 'Do...While' loop.

View 9 Replies View Related

Writing Udf For If Color Then Else

May 2, 2007

I am trying to write a UDF that will go like this:

IF A1 is Purple then B1=A1 Else B1=A2.

This is what I have written so far and I cannot figure out how to get it to work:

Function SumIfPurple( Range As Variant, Range1, Range2)
Dim SumAnswer
If Range.Interior.ColorIndex = 39 Then
Range1 = SumAnswer
Else: Range2 = SumAnswer
End If
SumIfPurple = SumAnswer

End Function

View 7 Replies View Related







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