I have a number of similar templates on a server used to produce quotations from other files with lookup formulas. They all have 2 modules, 3 & 4. Module 3 deletes certain data and shows values instead of formulas for most of the pricing etc. Module 4 contains a macro that logs info in another central workbook on the server.
If 2 files are opened based on the same template at once, when the Quote_Wrapup macro (in module3) is run on one of the open files(code follows) from a button on the spreadsheet it often produces a Run-time error '9' Subscript out of range error.
I have a Sub() in a module that sends an email to address that it retrieves from a spreadsheet.
See portion of code below
HTML Code: Do vaRecipient = Application.InputBox( _ Prompt:="Please add the name of the recipient such as:" & vbCrLf _ & "firstname.lastname@example.org or just the Staff ID.", _ Title:="Recepient", Default:=Range("I" & vaRow).Value) Loop While vaRecipient = ""
This is basically showing 3 popup boxes one after the other to verify each address,
Is it possible to either have it show an input box with 3 fields or ( what I'm currently trying) is to show a Userform . I have tried Userform12.show but it isnt working.
I want to allow users to place files (.jpg, .tif, .pdf, .pps etc) into a network folder and then have my program open each file and display it for 30 seconds then close the file and the application before opening the next file.
1. Set up a loop to get a directory listing of the folder and write the listing to a text file.
2. Open up the text file and get the next filename in it
3. Open the file in the associated application
4. Wait for 30 seconds (or some period of time) and then close the file
5. Repeat steps 2-4
DoIt = 1 While DoIt = 1 Open "C:TempList.txt" for output as #1 Print #1, Files In Folder Close #1
Open "C:TempList.txt" for input as #2 while not eof(2) Line input #2, MyFile Display MyFile on screen Wait for 30 seconds Close MyFile and MyApplication that opened it wend Close #2
I can get the directory listing just fine with no problems
I can open the files in the associated application just fine with no problems.
with closing the application after 30 seconds or some period of time.
I need some code that will allow me to easily send it a filename and it will know how to close the file and the application that opened it.
I have an Excel application (Excel 2003) which is stored in the default Program Files folder by the Installer; for example: c:program fileszxchello.xls. The problem I am running into is this file opens as Read Only in Vista and this is interfering with the running of the application. There is no problem opening the file normally in Windows XP.
I have been able to narrow down the cause of this to the User Account Control system in Vista - if I turn OFF User Account Control, the Excel file opens normally and my application functions normally. Is there another option to open the Excel file without turning OFF User Account Control because some users may find it unacceptable to turn OFF this security feature. Ofcourse, one option is to install the application in another location, outside the Program Folder, and the file would open normally, but the Packaging Wizard that I am using to package the application does not allow me to install the application in any other location and thus, the application installs in the Program Folder and I am running into this problem of the Exel file opening as Read Only. Is there a way out of this situation where I can open the file normally (not as Read Only)?
I inserted a second module into a project. Now I want to delete it. Only i can't figure out how to do this. I highlite it and right click or click edit from the toolbar but i'm provided no options. I can't drag it to the trash either.
I'm trying to open multiple files based on an array of WBnames that are on a 'Dashboard' tab, but I only want to open them if they are not already opened. The code below doesn't seem to check if they are open and just opens everything....
VB: Sub OpenWorkbooks() Dim WorkbookOpen() Dim WBnames() As String 'Array of WorkBooks to be Open Dim WorkbookCnt As Integer
I am using Excel 2010 and late binding to generate reports. The sheets are blank and unused. I have the UserForm being opened on Workbook_Open and the actual VBA for doing the work in a separate macro in the workbook. All the posts I have found are dealing with accessing cells from the UserForm and I haven't found any dealing with connecting a macro to the UserForm output.
My question is this: I want to return from the UserForm the flags of which reports to run to the (unopened) macro containing the code to do so. How do I open the macro and pass the variables to it?
The UserForm is creatively called "SelectionForm" and the macro is called "DailyFTP" with a Main sub as the entry. I know I can use the code under to capture the radio button and checkbox choices. I have other variables like the names of files set as global variables in the DailyFTP macro. The macro doesn't exist until SelectionForm opens it, so they must be set after the macro is in memory.
I have a problem deleting Module1 then saving the worksheet and keeping the module1 deleted. Without the rem'd code (shown below) a popup asks if you wish to save the changes; if you say "No" the module reappears in the file, and "Yes" the module stays deleted. Even with any of the Rem'd out code below the workbook is saved and closed, but on reopening the code module is still there. My problem is I don't want the user to have the choice, the workbook must be saved without the module. As this is a price quote program, with the module still in the Project, reopening and closing the saved workbook causes an error as the macro cannot find the deleted worksheets to delete! This is a very small test program for a much bigger one that has quite a bit of security in it.
Dim x As Object Application.DisplayAlerts = False
e = Sheets("Sheet1"). Range("B4") ' account name f = Format(Sheets("Sheet1").Range("B3"), "ddmmyy") ' date quote saved, cell = NOW() thisfile = e & "-" & "-" & f 'changed to name, Acc No, dat
how to write a procedure to delete macro code that is in the worksheet property? I created a and excel model for a colleague which had many macro procedures including "Worksheet_Activate". The problem is now this individual moves the worksheets into new workbooks and this is cause many runtime errors. Is there a way I can write a copy/move procedure that also deletes the Worksheet Activate macro so that error does not appear?
Dim myname As String myname = Application. GetOpenFilename
I use it to attempt to open first a QuickBooks file and then an excel workbook. The Quickbooks file opens fine. The Excel workbook never appears to open but I do get the full file pathname to my excel workbook returned which I then parse off to get just the workbook name.
Why would it behave this way? I open both these files manually all the time.
Also, I'm trying to use a filter as follows:
myname = Application.GetOpenFilename("*.QBW")
I get a compile error saying that I'm calling the function wrong.
I want to delete the contents of every cell without deleting any code from my module. The reason I ask is, I'm reading from a text file into excel.
I want to run my code to read text into excel one time through. Then i want to delete all the text, make some alterations to my code, and run the code again. That way each time the worksheet is fresh and clear before i run the code.
After all the awesome macros I've obtained with the help of all of you, I now have over 30 macros, each in its own module. I have tried without success to re-name the modules with no luck. How is everyone organizing these?
Is there a code that will search a pre-determined folder for all .xls files containing the word "Temp", and deleting those files?
Example: In the root of drive M, I have several Excel files. Anytime one of the original tracking logs is opened, a temp file of that log is automatically created. I would like to automatically search the drive and delete all files containin the word "Temp".
I've attached a picture of the directory tree, in case that will help. The file will always be named "PO Response Tracking - Temp#######.xls", with ###### representing a series of either 5 or 6 numbers.
I quite often bring spreadsheets home to work on, but in the last few days it seems that any sheet with a macro produces an error message when I try to open it on my home pc.
(Excel has encountered a problem and needs to close) The files are created with excel 2003 and my home version is 2002. Previously this has not been a problem. I can still load versions of the same spreadsheet from a week ago, but not any recent sheets containing macros. Macro security is set to medium - always was.
Is there a setting somewhere that could have inadvertantly been changed that is causing this problem?
I was trying to read BMP file. But when ever there are NULL char in File Left,Right doesn't work. Does any one have any alternative for this. For Eg. here are first 10 bytes of a BMP file. 42 4D 4E 01 00 00 00 00 00 00 3E
Open [C2].Value For Input As #BMP_Src 'Read BMP As Input File While EOF(BMP_Src) = 0 Line Input #BMP_Src, sTemp While Len(sTemp) ActiveSheet. Cells(iRow, iCol).Value = Left(sTemp, 1) 'Update readed Char x = Left(sTemp, 1) 'Temp Var to see Char sTemp = Right(sTemp, Len(sTemp) - 1) 'Remove Updatd Char iCol = iCol + 1 'Update Col Count If iCol > 10 Then 'Init Col Count iCol = 1 ' iRow = iRow + 1 'Inc Row Count End If Wend Wend
In this code after reading 4th Byte Code jump to 10th Byte. because Left, Right consider NULL as endof string. I asked this Question to know if there is any alternative way to read NULL char in VBA.
I would like to create a button that will open a file in a location based on the date of the file. So if I click the button the file with the latest date is activated as read only. The file name is always the same except, the date is added to the file name each day.
I am trying to create a template application where the user will use buttons to show the open file dialog box and select two files, and I want these files to open in the same workbook, in different sheets.
I have created a Spreadsheet that does all of the calculations, analysis, graphs, etc. that i need; however every time I wish to use this spreadsheet I need to first open up a spreadsheet with data, copy it and then paste it into the original spreadsheet. While this is not horrible, it is quite tedious to do several thousand times.
Thus, I was wondering if it were possible to create a Macro that would open up all files in a specific folder, then select each one and paste the relevant data into my original spreadsheet. I know this possible for specific files; for example, I have created a Macro that will select files data.xls, dats1.xls, data2.xls, and paste these into the spreadsheet, but I was wondering if there was a way to generalize this so that it will simply open every file regardless of the name or how many files there are in the specific folder.
I have files stored at C:KLQ1. Some with .xls and some with .xlsm. Now I want to same all the files under C:KLQ2 with .xlsm extension. Then replace all the 2005 with 2006 in the saved-as file. Then close all the files in Q1 without saving and all the files in Q2 with saving. The following code is modified from somewhere but does not work.
Sub OpenCloseFile() Dim i As Integer Dim wbResults As Workbook Dim ws As Worksheet