indicates the absolute address of the file, and linenum indicates the row number. 3 function readfile2 (path, linenum) 4': handle the error, can be removed. If there is an error, it will automatically jump to the error tag and execute 5 on error goto Error 6 7' to open the file, and use the symbol "1" instead of the file stream 8 open path for input as #1 9 10'
Json:javascript Object Notation (JAvaScript Object Notation) Similar to XML, in the form of text (saved in a text file or a string, for example), such as:JSSTR = {"Department": "History department", "Class": "Class", " student":[ {"name": "Zhang San", "Age": 25, "gender": "Male"}, {"name": " John Doe "," age ": 20,
The macros provided by word can provide us with sufficient help and support during VBA calls. , Convenient and fast.
Using Microsoft. Office. InterOP. word;Using system. IO;Using system. Web;Using Microsoft. Win32;Using system. Text. regularexpressions;Using system. net;
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
///
///
Import data
specific meanings, see the help of VBA.Example:Workbooks. Open "F:/test.xls"Open the test.xls file on the fdisk.
2. Open a text file
You can use the open method to open text files, but we recommend that you use the opentext method. This method loads a text
Testing often encounter the processing of data, such as I want to delete some specific data, the data source is fetched from the Web request, this time may be copied down a lot of content, where we only need certain parts, the author is usually copied to notepad++ processing, combined with regtester tools, But regtest need to export matching data, not directly copied, a little bit of trouble ... So I want to use VBA to write a regular expression extra
Add and remove modules for Excel VBA and insert full process text
Method/Step
1, click the Quick Launch bar Excel program icon to enter the Excel interface to select any cell and press ALT+F11 to enter the VBE interface
2, click the menu bar Insert command in the pop-up active menu click the module command
3, another way to insert the module can be in the project Capital Manageme
contains a comma character, which must be enclosed in double quotation marks. (The 6 ) field contains a newline character, which must be enclosed in double quotation marks. (7 ) contains spaces before and after the field, which must be enclosed in double quotation marks. (a b C ==> "a b C" ) (8 ) The double quotation marks in the field, expressed in two double quotation marks. (I said: "abc" .) ==> I said: abc. ) (9 ) if there are double quotes in the field, the field must be enclosed in
I used VBA to convert an Excel file to a file, but the date format in the converted text file is not the same as that in Excel, and the date format in Excel is, after the text format is converted, the date format is changed to 11/
. FileSystemObject ")Set F = FS. opentextfile ("C:/testfile.txt", forappending, tristatefalse)F. Write "Hello world! "'Write stringF. CloseEnd sub
· Writeline Method
Syntax: object. writeline ([String])
Function: Write a specified string and line break to a textstream file.
Example:F. writeline ("Hello world! ") 'Write a string with a line break.
· Writeblanklines Method
Syntax: object. writeblanklines (lines)
Function: Write a specified number of lin
In our daily use of Excel, we not only use the data of the current Excel file, but also frequently need to access other data files. These data files may be Excel files, text files, or database files. Some people often ask how to operate these data files in the VBA code? This article systematically introduces how to use VBA
ADODB. Stream to create a UTF-8+BOM encoded text file.
It then traverses the data area, formats the data, and outputs it.
Small data is OK, big data is not tested.
In addition, the text file created by using the FSO is encoded as Ansi,ajax parsing JSON does not parse corr
Workbooks. opentext (filename, origin, startrow, ype, textqualifier, delimiter, tab, semicolon, comma, space, other, otherchar, fieldinfo, textvisuallayout, delimiter, thousandsseparator, delimiter, local)
For more information about the meanings of the preceding parameters, see the help of VBA. In actual programming, it is generally not necessary to process these complex parameters. You can use a recording macro to obtain the
small character set, those characters outside the small character set are lost and cannot parse the correct text from it.* 4. Congratulations on your winning, there are some characters that use any kind of encoding no different or wrong coding does not lead to a bit supplement, then I can do nothing. (This is really rare)** Note: The program garbled text is Baid
informationActivesheet. PasteDim N as integerN = baselineStartline1 = n' the starting line for the parent account to Start copying
'Open each subaccount and copy the information to the parent accountFor I = 1 to countWorkbooks. Open filename: = currentpath Arr (I) 'Open the Excel file cyclicallySheets (1). SelectN = baseline'Start from the third line and find the end line of the subaccount InformationWith sheets (1)Do while. cells (n, 1).
'Vb/VBA for Database File Access
'The example database is an Access database. If you use the SQL database, you only need to change the connection string.
'
'*************************************** **********************************
'**
'** Use ADODB. Stream to save/read files to the database
'** Reference Microsoft ActiveX Data Objects 2.5 library and later
'**
'** ----- Database connection string template
Private Function selectfile (ByVal strfilter As String) as StringDim FileName as VariantThe file name returned by the Open File dialog box is a full path file name, and the value may be false, so the type is variantDim sfilename as String ' filename extracted from filenameDim spathname as String ' path name extracted from filenameDim afile as Variant ' array, usi
Here I will directly on the source:Sub Export Txt1 () Dim file as String, arr, I ' defines the name of the text file = Thisworkbook.path "\ New salary table. txt" ' Determines if there is a text file with the same name, there is an antecedent delete if Dir (
This note will be the operation of the previous note to make some improvements, no longer the HTM file in the Saz file parsing out, but not to read the data directly into the string, the basic idea is as follows:1. Customize a class that reads content from a text file to a string: Parses an HTM document in a saz
text data.Import HtmlparserImport UrllibClass ParseText (Htmlparser.htmlparser):def handle_data (self, data):if data! = '/n ':Urltext.append (data)Lparser = ParseText ()Lparser.feed (Urllib.urlopen (/http://docs.python.org/lib/module-HTMLParser.html). Read ())Once you have defined the new Htmlparser class, you need to create an instance to return the Htmlparser object. You can then use Urllib.urlopen (URL) to open the HTML document and read the conte
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.