w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Access 2010 - Create VBA Macro generate Text File
You'll need to get the recordset object and then do something like this: Open "yourfilename.txt" for Output as #1 While not (recordset.eof) Print #1, "FNN=" & recordset.fields("FNN").value (add the rest of your string here...) recordset.movenext Wend Close #1 Technically, instead of "#1" you should grab the file number by using the FreeFile() function.

Categories : Vba

Need the macro to run ok even when the selection includes cells that are empty or have text
As Andy G states - you need to run a check if the cell is empty and skip if so. You can do it like: Sub TimeCreator() Dim r As Range, t As String For Each r In Selection If r.Value <> Empty Then 'test if the cell is blank (note, a zero length string is not blank in Excel) t = r.Text 'r.Clear is unnecessary as you assign to r.Value r.Value = TimeSerial(Mid(t, 9, 2), Mid(t, 11, 2), Right(t, 2)) r.NumberFormat = "[h]:mm ""IT""" End If Next End Sub However, it would be better to only run the macro on cells that have values in the first place, which you can do using Range.SpecialCells(), like: Sub TimeCreator() Dim r As Range, rangeToRunOn As Range, t As String Set rangeToRunOn = Selection.SpecialCel

Categories : Excel

Convert to text using VB-macro (including line breaks within cells)
First you should Open the Textfile only ONCE and not for every Cell Then you can do Print #1, cell.Offset(0, 1).Text & vbnewline For the celltext and a new line.

Categories : Excel

Macro to open a delimeted text file in Text format
Not answer but suggestions. Excel does that automatically to predict what data type it should store and remove unnecessary details such as spaces and leading zeros. Workaround is what to do after text imported. Change the formatting of the columns so it displays leading zeros, or Change the value to Sting after the formatting Something like .Cells(R,C).Value = Format(.Cells(R,C).Value, "00000000") in a loop.

Categories : Excel

Excel Macro - Copy Range Of Cells in Sheet2 to Sheet 1 below Cell With Specific Text
Activesheet and Activecell are too vague. If you are working with a multisheet program it is good practice to specify which sheet you are working in or use a "With Sheets("Sheet1")" for a multiple of "Sheet1". This may not be a cut and paste but you get my meaning: Sub Sheetspractice() NumRows = Sheets("Sheet1").Range("L2:L" & Rows.Count).End(xlup).Row Sheets("Sheet1").Range("L2").Select For x = 1 To NumRows Sheets("Sheet2").Range("A1:G24").Select Selection.Copy Sheets("Sheet1").Cells.Find(What:="Recess Size", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate Sheets("Sheet1").Paste Sheets("Sheet1").Range("A1"

Categories : Excel

text file doesn't match when i try to create text box according to the text file
It's creating 10 more because you have 10 lines that ends with a comma. Say you have a string like: var s = "A,B,C," Splitting this would result in 4 string, the last one being empty. Now reproduce this for 10 lines and you will get the same behaviour as you are having. If that's unwanted behaviour, you need to change your logic to take into account a line that is ending with a comma.

Categories : C#

How to create an emacs macro for text templates
You can see similar macros in sgml-mode.el, for example html-href-anchor, which inserts an HREF anchor (obviously :-). You will get more specific answers if you tag this as [elisp].

Categories : C++

Reading exact columns of a text file and putting the values/text into a vector
Read a line in. Scan it for the various parts (numbers, first name, middle initial, last name, etc.) Put the elements into a structure that holds all of them. Put pointers to the structures in an array. Using one or more elements as keys, sort the structures as needed.

Categories : C

How to use strings from one text file to search another, and create a new text file with columns from another?
Here's an example, with input files in file1.txt and file2.txt. I cache the contents of file 1, and their associate output file handles in the dictionary 'files', which I then close at the end after the main loop. In the main loop, I read in each line of file2.txt, strip it, and tokenize it on spaces using the split method. I then find the ip address from the first token, and check if its in 'files'. If so, I write the third column to the respective output file. The last loop closes the output file handles. with open('file1.txt') as file1: files = {ip:open(ip + '.txt', 'w') for ip in [line.strip() for line in file1]} with open('file2.txt') as file2: for line in file2: tokens = line.strip().split(' ') ip = tokens[0][3:] if ip in files: file

Categories : Python

Create repeat excel macro code until no more text mentions
Not sure I understand but I think what your looking for is: For each cell in columns(4).cells If cell.value="Text to find" Then Cell.offset(0,1) = "Text to enter" Next cell

Categories : Excel

Conditional formatting cells based on sum of ajacent text values
I'd suggest three rules, two with Use a formula to determine which cells to format: =COUNTIF($B1:$F1,"N")=5 for Red =COUNTIF($B1:$F1,"Y")=5 for Green and as the default, Format only cells that contain, Format only cells with: Cell Value greater than =0 for yellow.

Categories : Excel

Excel - if cell contains (text) then paste (new text) - Macro required please
OK, as the comment mentioned, I don't think you need a Macro for this. Create a separate sheet(I always name mine "code"), and list the products in column A and the category in column B. This is what you will reference with VLOOKUP(). With this table created, the code in your category table will be something like =CONCATENATE(VLOOKUP(Product,Code!A:B,2,FALSE),">",Product) Which, if you've done it properly, should return "Tools>Hammer". I should note that "product" is the cell which contains the name of your product, if that isn't clear. There may be some issues with quotes, but I think that my code has it correct. You can also extend a VLOOKUP to refer to a lot of data, if that helps you later in your project. So you could include part #'s, etc. Hope this helps, it's much easier

Categories : Excel

How to use text file to load file paths to excel macro
Adapt as you see fit but you should get the idea! Const ForReading = 1 Set oFSO = New FileSystemObject Dim txtStream As textStream Set txtStream = oFSO.OpenTextFile("C:....PathtoFiles.txt", ForReading) Do Until txtStream.AtEndOfStream strNextLine = txtStream.ReadLine If strNextLine <> "" Then ' Do something? End If Loop txtStream.Close

Categories : Excel

VBA macro: replace text in word file in all sub folders
Your code worked for me with below changes From strFile = Dir(strFolder & varItem & "*.doc") To strFile = Dir(strFolder & varItem & "" & "*.doc") Make sure the path for folder is correct in strFolder Variable. Eg( strFolder = "C:UsersSantoshDesktop es")

Categories : Vba

Perl Program to Read a Text File, Search for text within the File and copy the text to a new file
Why not awk? awk '/ Directory of /{at=$3;print;next}{print $0""FS""at}' your_file Perl: perl -lne 'if(/ Directory of (.*)/){$a=$1;print}else{$_.=" ".$a;print}' your_file if you want to do an inline replacement: perl -i -lne 'if(/ Directory of (.*)/){$a=$1;print}else{$_.=" ".$a;print}' your_file

Categories : Regex

Read from text file, capture text, write to another text file in specific syntax
I'd personally do something like that with Perl, because I'm familiar with Perl and it works great for these kinds of tasks. You can also write a sed one-liner to get that done. If you're not a fan of Perl, any modern dynamic language should let you get the job done with minimal effort. EDIT: An example Perl script (full file for readability) would look like this: use warnings; use strict; while (my $line = <>) { $line =~ /^s*(.+?), '(.+?)', '(.+?)';$/; # Doesn't handle internal escaping print "DELETE ATTRIBUTE "$1" IN FOLDER "$2" FROM PROJECT "$3"; "; } See the result.

Categories : Misc

Importing Tab Delimited Text File with Multiline Cells (to Excel or Access)
Here's what I came up with. If you can guarantee the last column will never have a carriage return, then this should work ok. What this does is read the text file in VBA and brings it into the workbook. You have to specify how many fields to expect (in the test scenario, 4). This is so it can keep track of when it's ready to start a new row. It's a little confusing because of the carriage returns, but step through the code and I think you'll be able to figure it out. Let me know if you have any questions. Option Explicit Const fieldCount = 4 Sub import() Application.ScreenUpdating = False Dim fileNumber As Integer Dim data As String Dim curCol As Long, curRow As Long Dim dataCols As Long Dim i As Long Dim sh As Excel.Worksheet Dim arr() As String D

Categories : Excel

Macro combining multiple cells into one, with values separated by a comma
Have a look here: http://www.excelforum.com/tips-and-tutorials/860240-concatall-udf-by-tigeravatar.html The first post shows how to use it, and the 8th post is the most recent version. [EDIT] Alternately, just change both instances of & " " & to be & "," &

Categories : Vba

Excel macro that prints individual array values to cells
If your set of data begins in the same area each time and there are no empty cells between the data, you could always do something like: Dim rngData As Range Set rngData = Range("A2").End(xlDown) In the example above, I assume your data starts in cell A2 and remains in column A with no spaces between data. This is the equivalent of selecting cell A2 and holding shift and then pressing down. It will select all of the cells. You can then loop through each cell in your range and do whatever you need using a For ... Each loop like: For Each C in rngData 'Do whatever you want for each cell Next C You can use C as you would a cell. For example, C.Value will return the value of the individual cell you are on. This is quite broad because I'm unsure exactly how your data is set up, but

Categories : Arrays

Macro to iterate through all rows in all columns of a worksheet and compare a cell to copy the row to a text file
You can use the .Offset() method of Range object and vbTab constant to create tab delimited spaces The .Offset(rows, columns) takes 2 parameters. Number of rows up or down of the current cell. To navigate up you give it a negative value to go down a positive one. Same applies to columns except that you use a negative to move left and a positive to go right. vbTab creates a tab between two objects in the context of "this is " & vbtab & " tab delimited" I have modified your comparison method a bit and added the StrComp() function. It is more reliable and you can specify the comparison parameters. Please see how to compare strings in VBA for more details about the = operator in string comparison. I have changed your Sheet4.Range("K1:K300") as this is a bit misleading and wrong

Categories : Excel

Change encoding of text file (shell archive or script for antique kernel text to ASCII text, with CRLF, LF line terminators)
Unix uses a single character for line termination. If you want to convert your file with CRLF to single character termination, you can do the following: sed -e 's/<CTRL-V><CTRL_M>//' filename where <CTRL-V> is the Control key pressed with V (do not include < and > characters in the command.

Categories : Bash

create a batch file to open firefox, then run a macro (wait for it to finish) then run another macro
Now that the macros delete this temp file when they finish, this should work: @echo off ECHO You have 5 sec to close this Window to prevent the Macro from running... timeout 5 ECHO Start Firefox and wait another 10 seconds... start /B "" "C:Program Files (x86)Mozilla Firefoxfirefox.exe" timeout 10 set "tempfile=C:UsersPublicDocumentsiMacrosMacrosflag.txt" echo macro 1 running type nul>"%tempfile%" start "" /w /b "C:Program Files (x86)Mozilla Firefoxfirefox.exe" imacros://run/?m="mymacro1.iim" :loop1 if exist "%tempfile%" ping -n 10 localhost >nul & goto :loop1 echo macro 2 running type nul>"%tempfile%" start "" /w /b "C:Program Files (x86)Mozilla Firefoxfirefox.exe" imacros://run/?m="mymacro2.iim" :loop2 if exist "%tempfile%" ping -n 10 localhost >nul & got

Categories : Batch File

Inserting text from text file into MySQL TEXT column
This is a possible duplicate of this question: http://serverfault.com/questions/316691/mysql-binlog-format-dilemma Anyway, the key is Statement is unsafe because it uses a system function that may return a different value on the slave. When the MySQL database is setup to use replication, system functions like load_file can cause issues. The file C: emp exttoinset.txt is likely different between the master server and the slave server (or may not even exist on one of them). When using replication, it is best to avoid system functions (like load_file and NOW()) because the values will be different when executed on different servers. If you want to load a file into a MySQL database that uses replication, consider using PHP's file_get_contents to read the file, and then use that to insert

Categories : PHP

How to extract two folder path C: (same Type File: e.g Text Document) and name of the file into text file with the file size in kb
The error you observe is caused by the signature of your procedure ListFiles. In VBScript all variables/parameters are of type Variant, so you must not explicitly specify a type. Change this: Sub ListFiles(f, folderPath As String, fileType As String) into this: Sub ListFiles(f, folderPath, fileType)

Categories : Vbscript

Why will Qt not create a text file when running or debugging from inside Qt, but will create it when directly from the debug folder?
You probably used a relative path, and inside QtCreator the "current directory" from where the executable is ran is not necessarily the directory where the executable is. Try: qDebug() << QDir::currentPath(); It will tell you where you should expect your file to be written.

Categories : C++

Matlab reading hex values from text file with non hex values interspersed?
This solution reads 1 million 2-character lines in less than a second on my laptop: fid = fopen('test.txt'); A = textscan(fid,'%2c','CommentStyle','XX'); fclose(fid); A = hex2dec(A{:}); Note the 'CommentStyle' option that skips those lines that start with XX.

Categories : Matlab

Create a search box that returns several hidden text values
i found something like this... Array.prototype.vlookup = function(needle,index,exactmatch){ index = index || 0; exactmatch = exactmatch || false; for (var i = 0; i < this.length; i++){ var row = this[i]; if ((exactmatch && row[0]===needle) || row[0].toLowerCase().indexOf(needle.toLowerCase()) != -1) return (index < row.length ? row[index] : row[0]); } return null; } this is the source http://brad-christie.com/blog/2011/03/02/vlookup-for-javascript/ give it a try...!

Categories : HTML

How to create spaced text fields with a description of the text field at the top of each text field
hope the following code will help you, You have to place TextView in between EditText to give reference, <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".AddContact" > <TextView android:id="@+id/lbl_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="User Name" /> <EditText android:id="@+id/edit_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="Enter name" > </EditText> <TextView a

Categories : Android

how to create input (type = text) which accepts values from select option?
Chosen and Select2 are more suitable for this than typeahead: Chosen http://harvesthq.github.io/chosen/ Select2 http://ivaynberg.github.io/select2/

Categories : Javascript

Batch file to create multiple variables from single lines in a text file
This should work: @echo off setlocal EnableDelayedExpansion set "Count=1" for /f "tokens=1,2,3,4,5,6,7 delims==: " %%A in (C:File.txt) do ( set "%%A[!Count!]=%%C" set "%%D[!Count!]=%%E" set "%%F[!Count!]=%%G" set /a "Count+=1" ) :: Call other batch script here. endlocal Example Output: COMPUTER[1]=PC COMPUTER[2]=PC2 ADDRESS[1]=154.100.1.1 ADDRESS[2]=100.100.1.1 MASK[1]=255.255.254.0 MASK[2]=255.255.254.0

Categories : Batch File

How can i create dxdiag.txt file automatic ? ( DirectX information text file )
This is rather a Windows batch script question, to get the date, you can use the following command echo %date% This generate the output as Wed 07/24/2013, to convert the date to the format you want, you can use %date:~i,n% where i is the start index of the sub string and n is number of characters to get. for example %date:~10,4% will get 2013(4 digits for year) full code echo off set today=%date:~7,2%-%date:~4,2%-%date:~10,4% echo %today% this will get the date string of today, the output is 24-07-2013, you can then insert this string to your script.

Categories : C#

perl script using XML parser to read values in text file and replace it xml file
A solution using XML::XSH2, a wrapper around XML::LibXML. #!/usr/bin/perl use warnings; use strict; use XML::XSH2; open my $INS, '<', 'install.properties' or die $!; while (<$INS>) { chomp; my ($var, $val) = split / = /; # / fix StackOverflow syntax highlighting. $XML::XSH2::Map::ins->{$var} = $val; } xsh << '__XSH__'; open property.xml ; for /properties/entry { set ./text() xsh:lookup('ins', @key) ; } save :b ; __XSH__ The same programme imlemented using only XML::LibXML: #!/usr/bin/perl use warnings; use strict; use XML::LibXML; open my $INS, '<', 'install.properties' or die $!; my %ins; while (<$INS>) { chomp; my ($var, $val) = split / = /; # / fix StackOverflow syntax highlighting. $ins{$var} = $val; } my $xml =

Categories : Perl

Button to open text file won't function with text file not in class root directory
This is windows specific code, I think the problem is using the file separator "/" instad of "", try changing your code to Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + "config\gameItems.txt");

Categories : Java

Batch file to loop through contents of a text file, create variables and move files with partial names
Test this - the top portion creates the test files and folders. It then moves the files as you seem to want them moved. @echo off md "c:mylibrary2Accident Investigation Report" 2>nul md "c:mylibrary2Address Change" 2>nul type nul > "c:mylibrary2Accident Investigation Report2013-06-06 16-28-59 165 Accident Investigation Report - J Bloggs.pdf" type nul > "c:mylibrary2Accident Investigation Report2013-06-06 16-28-59 165 Accident Investigation Report - J Bloggs.xml" type nul > "c:mylibrary2Address Change2013-06-06 16-28-59 165 Address Change - J Bloggs.pdf" type nul > "c:mylibrary2Address Change2013-06-06 16-28-59 165 Address Change - J Bloggs.xml" type nul > "c:mylibrary2Accident Investigation Report2013-06-11 15-38-07 147 Accident Investigation Report - L Test.pdf" typ

Categories : Windows

IOS create PDF file with rotation text
The following adds text rotated -90 degrees to the specified context at the yOffset from the top of the page: +(void)addRotatedLabel:(CGContextRef)context atYOffset:(CGFloat)yOffset{ // -90 degrees CGFloat rotation = -M_PI / 2.f; CGContextRotateCTM(context, rotation); NSString *label = [NSString stringWithFormat:@"%@", @"some text"]; CGSize maxSize = CGSizeMake(300, 12); UIFont *font = [UIFont systemFontOfSize:7.5f]; CGSize textSize = [label sizeWithFont:font constrainedToSize:maxSize lineBreakMode:NSLineBreakByClipping]; CGRect titleRect = CGRectMake(-yOffset, 32.f - textSize.height + 3.f, textSize.width, textSize.height); [[UIColor blackColor] setFill]; [label drawInRect:titleRect withFont:font]; CGContextRotateCTM(context, -rotation); }

Categories : IOS

Is there a way to create a text file using a string name in C#
Of course. The first argument to the FileStream constructor takes a string. You've just passed it a string literal (defined in your source code file). It sounds like you want to pass a string variable instead: string path = // get string from somewhere. A file save dialog, maybe? FileStream fs = new FileStream(path, FileMode.Append, FileAccess.Write); StreamWriter sw = new StreamWriter(fs); May I suggest that you spend some time with a C# tutorial? Microsoft has some good tutorials and samples. With all due respect, and we were all there once, you've got some holes in your knowledge that will trip you up.

Categories : C#

Open txt file, create new txt file, save old text to new file
The line outfilename$.SaveAs =:"FileName"infilename.txt",False" looks quite wrong indeed. You coud try this instead to pop-up a dialog for saving file outfilename$ = Application.GetSaveAsFilename(infilename$, "Neutral Files (*.txt),*.txt", , "Save file", "SAVE") Update : The full code is Sub test() Dim outfilename as Variant Dim infilename as Variant Dim msg As Variant infilename = Application.GetOpenFilename("Neutral Files (*.txt),*.txt", , "Open Neutral File", "OPEN", False) If infilename = "False" Then msg = MsgBox("No input file selected. Press OK to retry or cancel to quit", vbOKCancel) If msg = vbOK Then Do While msg <> vbCancel 'loop until user presses cancel infilename = Application.GetOpenFilename("Neutral Files (*.r01),*.r01", , "Open

Categories : Vba

how to avoid NaN in the text box before adding the other text box values in javascript
Try this: <script> function totalValue() { var a = document.getElementById("a").value || 0; var b = document.getElementById("b").value || 0; var c = document.getElementById("c").value || 0; var d = parseFloat(a)+ parseFloat(b)+ parseFloat(c); document.getElementById("total").value = d; } </script> Fiddle: http://jsfiddle.net/AvzwM/

Categories : Javascript

How do I load text from a text file and compare against another text file?
You can read the dictionary file line by line. assuming that each line contains a single word you need to put that line into a hashset. Then you can go over the words that you read from the first file, reverse each of them and check that the reversed word is in that hash set. public Set<String> readFileIntoSet(String fileName) { Set<String> result = new HashSet<String>(); for (Scanner sc = new Scanner(new File(fileName)); sc.hasNext(); ) result.add(sc.nextLine()); return result; } In your main method add a call to readFileIntoSet: Set<String> dictionary = readFileIntoSet("your_dictionary_file"); Then, after you find the reversed word, check that it appears in the dictionary: if (dictionary.contains(reverseWord)) system.out.println("this word: "

Categories : Java

how to write a batch file which can identify value from a text file and store that value in some other text file
This example will work for integer numbers between spaces. Special caution must be put in text file, as behaviour for ", <, |, > and & may be unpredictable. Some optimizations may be made having more information about text file. For /F "Tokens=*" %%i In (TextFile.txt) Do Call :GetNumber %%i GoTo :EOF :GetNumber If "%~1"=="" GoTo :EOF Set Number= Set /A "Number=1*%~1" If "%Number%" == "%~1" Call :StoreNumber %Number% Shift GoTo :GetNumber :StoreNumber Echo %Number%>Number.txt

Categories : Batch File



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.