手机网站发展,wordpress 公众号 采集器,监理网站建设价格多少,建设工程抗震管理条例VSTOVBA 前言VSTO 外接程序介绍#xff1a;VSTO参考链接#xff1a;VSTO 例子#xff1a; VBA:参考链接#xff1a; 前言
主要用于Excel插件。 VSTO 外接程序介绍#xff1a;
Excel、Word、PowerPoint、Project、Visio等等Office应用程序 相对简单
VSTO参考链接#x… VSTOVBA 前言VSTO 外接程序介绍VSTO参考链接VSTO 例子 VBA:参考链接 前言
主要用于Excel插件。 VSTO 外接程序介绍
Excel、Word、PowerPoint、Project、Visio等等Office应用程序 相对简单
VSTO参考链接
知乎教程、官网参考、Api
VSTO 例子
1. 下标从1开始
public static int GenerateRandomSeed() Math.Abs((int)DateTime.Now.Ticks);//根据时间生成序列号
public Excel.Application excelApp;//Excel应用程序变量
excelApp Globals.ThisAddIn.Application;//构造函数里面
Excel.Workbook wbk excelApp.ActiveWorkbook;//wbk为活动工作簿
wbk.Path//当前路径
Excel.Sheets sheets excelApp.ActiveWorkbook.Worksheets;//wbk为活动工作表
TaFirstList ((dynamic[,])sheet.Range[A1, N1].Value).OfTypestring().ToList();
TaFirstList ((dynamic[,])sheet.Range[A1, N1].Value).OfTypedynamic().ToList();//为null的也算一个
//赋值
var firstlist new string[]{1,2,3,4,5,6};
Excel.Workbook Nowbook excelApp.Application.Workbooks.Add();//新增一个工作薄
Nowbook.Sheets[1].Name ;
Nowbook.Sheets[1].Range[A1].Resize[1, firstlistTPlm.Length] firstlistTPlm;
var str wbk.Path \\ wbk.Name.Split(.).First() test.xlsx;
Nowbook.Sheets[1].Cells[1, 2].Value flag;
if (File.Exists(str)) File.Delete(str);
Nowbook.SaveAs(str);//询问框
//添加一个询问框public partial class InputDialog : Form
{public InputDialog(){InitializeComponent();}public delegate void TextEventHandler(string strText);public TextEventHandler TextHandler;private void btnOk_Click(object sender, EventArgs e){if (null ! TextHandler){TextHandler.Invoke(name.Text);DialogResult DialogResult.OK;}}private void txtString_KeyPress(object sender, KeyPressEventArgs e){if (Keys.Enter (Keys)e.KeyChar){if (null ! TextHandler){TextHandler.Invoke(name.Text);DialogResult DialogResult.OK;}}}}
//调用类
public static class InputDialogWin
{public static DialogResult Show(out string strText){string strTemp string.Empty;InputDialog inputDialog new InputDialog();inputDialog.TextHandler (str) { strTemp str; };DialogResult result inputDialog.ShowDialog();strText strTemp;return result;}
}
//使用
DialogResult dialogResult InputDialogWin.Show(out currentName);
if (dialogResult DialogResult.Cancel) return;VBA:
参考链接
语言基础 教程一
1. 开发工具VBA编辑器视图 - 立即窗口:
? 11 ? len(qiou.eu) //问号是一定的
VB 基本语法部分
Sub/Function/Class/Module 【1】
数据类型 【3】
String, Number, Date以及常用方法
Array
流程控制 【2】
If While Foreach Fori Switch
Goto, With
异常处理 【1】
On Error xx
抛出及捕获异常
Excel对象模型
Range 【2】
Worksheet, Workbook, Application 【2】
不同Office产品之间的交互 (*视反响决定) 【2】
MS Office 常用内置库
FileSystemObject 以及基本IO 【2】
Dictionary 以及容器操作 【2】
RegExp 以及 高阶字符串处理技巧 【2】
JavaScript-Engine (*视反响决定) 【2】
Excel事件模型以及用户表单
Workbook, Worksheet事件模型 【1】
Excel用户表单 【2】
面向对向编程定义自己的Class文件
简单的OOP(Object Oriented Programming)介绍 【2】
实例 (*安利我自己的 Excel Dicts/Lists库, 视反响决定) 【5】//变量强制申明, VBA版的use strict;
//此段VBA人代码中的程序入口main
Option Explicit
Public Sub main() helloWorld
End Subpop out the message
Private Function helloWorld() MsgBox Hello World!
End Function
---
Option Explicit
Public Sub main() Debug.Print getLongerStringLen(qiou.eu, sgfxq)
End Subreturn the length of the longer string
Private Function getLongerStringLen(str1 As String, str2 As String) As StringgetLongerStringLen IIf(Len(str1) Len(str2), str1, str2)
End Function//变量类型定义
Dim productName As String
Dim length As Integer
Dim reg As RegExp