The following VBA code feature uses loops to manipulate the collection of tables in Word, to set the borders of a table, and so on.
Dim I as Table, N as Integer
On error Resume Next ' Ignore error
application.screenupdating = False ' Turn off screen update
For all I in activedocument.tables ' loops in the table
With I
. style = List Type 4 ' Sets all tables to list Type 4 '
With. Borders ' border
.
First, primary knowledge classNow, please open your VBE, main menu-Insert-class module.A class module is inserted, and a class is created. The name of the class module is the name of the class. What you see now, her name is "Class 1", this is VBA according to her sister ranked her, yes, VBA has always been so, you are familiar with this rule, now, in the standard module or other modules to enter the Dim ...
--------------------
VBA syntax BASICS (II)--------------------
Basic statement
1. Control Program Flow Statement
(1) GOTO statement
This statement transfers the executed program to the statement instruction where the specified tag is located, but cannot be transferred to an instruction outside the process. For example, when an error occurs during error capture, the program is transferred to the tag for execution.
(2) If... Then statement
This type
We finally started the long-awaited VBA intermediate class! We are honored to be the first student in the intermediate class. Now let's start a new VBA journey!1. variable naming rules 1.1 Variables
Some data changes during program execution. Therefore, we allocate a memory location to store the uncertain data, which is a variable. Each variable has a variable name and must be unique within the same range.
Many people must know about macros and may have used macros. What is Macros? A macro is a program compiled by VBA. It is a series of commands and functions stored in the Visual Basic module and can be run at any time when the task needs to be executed. How to start learning VBA? This is one of the frequently asked questions of many friends. I personally think that the best way to learn something is to start
I learned to use VBA to connect to PHP's API, which is what my php function says:
public function vba() { echo 170982358; }
Using the thinkphp to change the routing rules, the function is made into a page.
But when called with VBA, this is the case:
Although also returned the result 170982358, but the mess;
But the other people's API returne
Translator Note:This article is greatly accompanied by translation from the www.vba-ie.net of the course, only to do Japanese learning, such as reproduced in this article please inform. all of the text is not replaced with Chinese interface, because the author of the computer is also a Japanese system, hope to understand. As a primer, this tutorial covers the basics of controlling IE from using VBA, getting data from a Web page , to a broader range of
When you write VBA code in Excel, the most common thing you can do is manipulate the data in the cells in the form. I'll summarize here how to manipulate the data in a cell from VBA code.The Range object is required to manipulate cells in VBA code, and range is a class provided by the Excel library (that is, the Excel.exe file), encapsulating all operations on ce
Procedures and parameters of VBA the procedure in VBA (Procedure) has two kinds, one called function and the other is subroutine (subroutine), using function and sub keyword respectively. They are an independent process that can get parameters, execute a series of statements, and change the values of their parameters. Unlike the Function procedure, a Sub procedure with a return value cannot be used in an ex
When we are programming with Excel, we often need to use a database.
So how do you connect the database and then read the data from the database?
VBA connects to an instance of SQL SERVER database:
Dim strconn As String, strSQL as String Dim conn as ADODB. Connection Dim DS as ADODB. Recordset Dim col as Integer ' connect the database string strconn = ' Provider=SQLOLEDB.1; Persist Security info=true; User Id=[user]; Password=[password];initial
Yesterday afternoon began to learn the VBA, exhausted, there must be bugs, to be debuggedThe VBA program is as follows:1 DimAsum as Integer2 DimTSum as Integer3 DimJudge -) as Integer4 DimArrmax as Integer5 Dimarr6 DimLocation -) as Integer7 8 FunctionTest ()9 DimArrwmax as IntegerTen DimRng asRange One DimBeginrow as Integer A DimBeginline as Integer - - SetRng = Application.inputb
Tags: VBA SQL Server Excel VBA connects SQL Server database operations to Excel.Sub button 1_click ()Dim I As Integer, J As Integer, sht as Worksheet ' i,j As Integer variable, sht as an Excel sheet object variable, point to a worksheet' Dim cn as New ADODB. Connection ' Define the data link object, save the Connection database information; First, add the ADO reference' Dim rs as New ADODB. Recordset ' D
To create a xlsm workbook:Macro workbook, you must have a VBProject object, at least one worksheet1 stringPath =@"E:\studyvs\open xml\test.xlsm";2 varPackage =Newexcelpackage ();3Package. WORKBOOK.WORKSHEETS.ADD ("Sheet1");4 //Create a Project object5 Package . Workbook.createvbaproject ();6 //Save Workbook7Package. SaveAs (NewFileInfo (path));8System.Windows.Forms.MessageBox.Show ("created successfully");To write code to a macro file:1 stringPath =@"E:\studyvs\open xml\test.xlsm";2 varPackage =
In VBA Engineering, VBA code is stored in a composite document in a compressed form.The extracted code is as follows: Public FunctionDecompression (Arrbyte () as Byte) as Byte() 'unzip the VBA stream 'Algorithm Description: https://msdn.microsoft.com/en-us/library/cc313094 (v=office.12). aspx DimCompressedcontainer () as Byte DimSignaturebyte as Byte
Http://vbaexcel.eu/vba-macro-code/vba-error-handling-on-error-resume-next
This macro code enables the on error resume next function. Explanation
To enable on error resume next will make the VBA program skip code that generates an error and normally stops the program.
A basic example file of the VBA macro is
1. If you want to update the chart with the raw data, you cannot directly use the value of the source data. Instead, you must reference the address (which must also be in r1c1 format). For example:Click to expand
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->Dim s as series
...
Set Rg = range (worksheets ("sheetxxx"). cells (1, 2), worksheets ("sheetxxx"). cells (6, 2 ))
...
S. Values = "= 'sheetxxx '! " RG. Address (referencestyle: = xlr1c1)
]::releasecomobject ($Excel) | Out-nullThe work is done here, and the improved script is the next thing.VbaAnother way is to use the office-brought macro to do this, open Excel press ALT + F11 after you can call the VBA editor, if you can not be the first to install Office when the macro component is not selected.The methods in VBA are very similar, except that they operate in different objects.Sub splitshe
found that the VBA function of Excel is a sharp blade of batch processing, working small and medium-sized test sledgehammer, will excel in the form of minutes and seconds of the coordinate batch processing into 10 system form, after processing for GIS exhibition point mapping.The original Excel data is as follows:The VBA code is as follows:1 SubCoorder ()2 DimLongitude, Latitude as String, arr3 DimN
In Excel, in order to enhance the contrast of the active cell, sometimes we need to modify its background color, font, font size, and so on, to differentiate and other cell contrast!
In this tutorial, let's learn how to make Excel active cells have the background color in rows and columns, first look at the figure below.
In the picture above, that is, C3 cell, is selected by the mouse, indicating that the active cell, how to do as shown above, C3 active cell row and column, the bac
Male colleagues from the engineering department of the company, the top three with the strongest Excel capabilities, are known as: big cousin, two cousin, three cousin
Female colleagues in the company's finance department, the top three with the strongest Excel capabilities, are called: big cousin, two cousin, three cousin
Want to be your company's "cousin" and "cousin "?
But not VBA.
So,
I'm coming!
"Excel 2013
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.