社区
VBA
帖子详情
Application.Workbooks.Open FileName
paul2002
2006-09-20 02:18:57
在VBA中用Application.Workbooks.Open FileName 可以打开excel文件,但是当EXCEL在IE中in-place打开时,该方法失效,请问怎样解决?
3X
...全文
375
7
打赏
收藏
Application.Workbooks.Open FileName
在VBA中用Application.Workbooks.Open FileName 可以打开excel文件,但是当EXCEL在IE中in-place打开时,该方法失效,请问怎样解决? 3X
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
m00ners
2006-12-01
打赏
举报
回复
不懂。帮顶
wada0880
2006-11-10
打赏
举报
回复
不明白
Dunzip
2006-11-08
打赏
举报
回复
关注
jam021
2006-11-08
打赏
举报
回复
没看明白,关注中
hhjjhjhj
2006-09-21
打赏
举报
回复
Dim xlapp As New Application
xlapp.Visible = True
xlapp.Workbooks.Open FileName
======================
欢迎光临“OFFICE论坛”http://office.9zp.com
happy_sea
2006-09-21
打赏
举报
回复
不会,帮顶!
paul2002
2006-09-21
打赏
举报
回复
没人气啊
excel control by delphi
//About my self excel control ..... study data // for your information... unit toxls5butt; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Excel2000, OleServer; type TForm1 = class(TForm) Button1: TButton; Button2: TButton; Button3: TButton; Button4: TButton; CheckBox1: TCheckBox; Button5: TButton; SaveDialog1: TSaveDialog;
Open
Dialog1: T
Open
Dialog; // Excel
Work
sheet1: TExcel
Work
sheet; // ExcelOLEObject1: TExcelOLEObject; // Excel
Work
book
1: TExcel
Work
book
; // Excel
Application
1: TExcel
Application
; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button4Click(Sender: TObject); private v:variant; sheet:variant; { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation { *.dfm} uses comobj; procedure TForm1.Button1Click(Sender: TObject); begin try V:=createoleobject(‘excel.
application
‘); v.visible:=checkbox1.Checked; v.
work
book
s.add; v.
work
book
s[1].
work
sheets[1].name:=‘good‘; sheet:=v.
work
book
s[1].
work
sheets[1]; sheet.cells[3,1]:=‘31‘; sheet.cells[2,1]:=‘21‘; sheet.cells[1.5]:=‘15‘; sheet.cells[2,2]:=‘22‘; v.
work
book
s[1].
work
sheets[2].name:=‘love‘; sheet:=v.
work
book
s[1].
work
sheets[2]; sheet.cells[3,4]:=‘34hello‘; // sheet:=v.
work
book
s[1].
work
sheets[‘helloaaa‘]; except showmessage(‘excel init load error, not excel or other error!‘); v.displayalerts:=false; v.quit; exit; end;
application
.Restore;
application
.BringToFront; end; procedure TForm1.Button2Click(Sender: TObject); begin if
open
dialog1.Execute then begin try V:=createoleobject(‘excel.
application
‘); v.visible:=checkbox1.Checked; v.
work
book
s.
open
(
open
dialog1.
File
Name); except showmessage(‘excel init error, not excel or other error, try again‘); v.displayalerts:=false; v.quit; exit; end;
application
.Restore;
application
.BringToFront; end; end; procedure TForm1.Button3Click(Sender: TObject); begin try if not varisempty(v) then begin v.DisplayAlert:=true; v.
work
book
s[1].close(true,‘c:untitled.xls‘); v.
work
book
s[1].close(true,‘*.xls‘); v.quit; end; finally close; end; end; procedure TForm1.Button4Click(Sender: TObject); begin if
open
dialog1.Execute then begin try v:=createoleObject(‘excel.
application
‘); v.visible:=checkbox1.Checked; v.
work
book
s.
open
(
open
dialog1.
File
Name); sheet:=v.
work
book
s[1].
work
sheet[1]; sheet.pagesetup.printtitlerows:=‘$1:$3‘; //page head sheet.pagesetup.printtitlecolumns:=‘‘; sheet.pagesetup.leftfooter:=‘Noted: PageHead‘+‘sum total&N page ‘+‘--No.&Page‘; //pagehead sheet.pagesetup.leftmargin:=30; //偞离?擒 Sheet.PageSetup.RightMargin := 30; Sheet.PageSetup.TopMargin := 30; Sheet.PageSetup.BottomMargin := 50; Sheet.PageSetup.PrintQuality := 300; //賤昴僅(跦?荂桶復隅) Sheet.PageSetup.CenterHorizontally := True;//岆瘁阨懈笢 Sheet.PageSetup.CenterVertically := True; //岆瘁晶眻懈笢 Sheet.PageSetup.Orientation := 2; //砃蹈荂 Sheet.PageSetup.Draft := False; //準翌詨耀宒 Sheet.PageSetup.FirstPageNumber := xlAutomatic; Sheet.PageSetup.BlackAndWhite := false; //窪啞詨 Sheet.PageSetup.Zoom := 100; //窺溫 sheet.PrintPreView; //蹈荂蕼罜 except Showmessage(‘initiale error ㄛnot Excelㄛor other error ˙try again!‘); v.DisplayAlerts := false; v.Quit; // finally exit; end; end; end; end.
Delphi7 向Excel文件中插入多种图表.rar
Delphi7 在Excel中插入图表,向excel中插入圆饼图表、柱状图表、圆锥图表、棱锥图表这四种图表,需要你的电脑上之前安装有Excellent2003、2007等版本,不过高版本没有测试是否可用,我觉得这个功能还是挺实用的: begin Excel :=CreateOleObject('Excel.
Application
');
Work
Book
:= Excel.
Work
book
s.
Open
(
File
Name := Extract
file
Path(
Application
.ExeName) '
Book
2.xls');
Work
Sheet := Excel.Sheets.item['Sheet1']; Excel.Visible := true; ChartObject :=
Work
Sheet.ChartObjects.Add(100, 100, 400, 300); ChartObject.Chart.ChartType :=temp; ChartObject.Chart.SetSourceData(
Work
Sheet.Range['A1:E5']); end
Delphi 将Excel表存入到html中的源码.rar
Delphi 把excel内容转换成HTML格式,将Excel表存入到html中的实例源码,后边会附上源码下载地址,转换过程可参考以下代码: if Edit1.Text<>'' then begin ExApph := CreateOLEObject('Excel.
Application
'); ExApph.visible := True; ExApph.
Work
Book
s.
Open
(Edit1.Text); ExApph.Active
Work
book
.SaveAs(Extract
file
path(
Application
.ExeName) 'mm.htm',xlHtml); ExApph.quit; ExApph := unassigned; end else showmessage('请选择Excel表'); 保存Excel文件的代码如下,完整源码请下载查看: procedure TForm1.SpeedButton1Click(Sender: TObject); begin
Open
Dialog1.Filter := '*.xls|*.XLS'; if
Open
Dialog1.Execute then Edit1.Text :=
Open
Dialog1.
File
Name else Edit1.Clear; end;
C# 通过反射调用com组件
C# 通过反射调用com组件,封装了几个简单的方法方便使用反射调用com。 var obj=new ComObj("excel.
application
"); obj["Visible"]=true; obj. InvokeMethod("
Application
.
Work
book
s.
Open
",
file
Name);
自动出题 自动生成EXCEL表格
private void Save2Excel() { //string
file
= "F:\\11\\ck.xlsx"; //string path = "F:\\11\\excel\\"; string time = DateTime.Now.ToString("yyyyMMdd"); string
file
= System.Windows.Forms.
Application
.StartupPath + "\\ck.xlsx"; string path = System.Windows.Forms.
Application
.StartupPath + "\\excel\\"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } string saveName1 = path + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xlsx"; excel = new CCExcel(
file
,saveName1); excel.Exceldata(); } private void textBox1_TextChanged(object sender, EventArgs e) { Form1.name = textBox1.Text.ToString(); } private void Form1_Load(object sender, EventArgs e) { comboBox1.Text = 11.ToString(); comboBox2.Text = 100.ToString(); } private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { Form1.comB1 = comboBox1.Text.ToString(); } private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { Form1.comB2 = comboBox2.Text.ToString(); } } public class CCExcel { public Excel.
Application
appExcel; public Excel.
Work
book
s wbs; public Excel.
Work
book
wb; public Excel.
Work
sheets wss; public Excel.
Work
sheet ws; private string
file
Name; private string saveName; public CCExcel(string
file
Name,string saveName) { // //TODO: 在此处添加构造函数逻辑 // this.
file
Name =
file
Name; this.saveName = saveName; } public void Exceldata() { Create(); //
Open
(
file
Name); Data2Excel(); Save(saveName); //Save(wb,saveName); //appExcel.Active
Work
book
.SaveCopyAs(
file
Name); //判断当前激活的表,并保存这个表。否则,保存时会弹出“是否保存Sheet1.xlsx”的对话框 wb.Close(Type.Missing, Type.Missing, Type.Missing); wbs.Close(); appExcel.Quit(); wb = null; wbs = null; appExcel = null; GC.Collect(); } private void Create()//创建一个Excel对象 { appExcel = new Excel.
Application
(); wbs = appExcel.
Work
book
s; wb = wbs.Add(true); //ws = (Excel.
Work
sheet)wb.ActiveSheet;//这是一个只读sheets集合 //Excel.
Work
sheet
work
sheet = wb.ActiveSheet as Excel.
Work
sheet;//这也是一个只读sheets集合 //Excel.
Work
sheet ws = (
Work
sheet)wb.
Work
sheets[1];//创建工作页sheet单页 ws = wb.
Work
sheets[1] as
Work
sheet; //第一个sheet页 ws.Name = "ck"; //这里修改sheet名称 } public void
Open
(string
file
Name) { appExcel = new Excel.
Application
(); wbs = appExcel.
Work
book
s; wb = wbs.Add(
file
Name); wb = wbs.
Open
(
file
Name,Type.Missing,Type.Missing,Type.Missing,Type.Missing, Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing, Type.Missing,Type.Missing,Type.Missing,Type.Missing,Type.Missing); }
VBA
2,503
社区成员
10,829
社区内容
发帖
与我相关
我的任务
VBA
VBA(Visual Basic for Applications)是Visual Basic的一种宏语言,是在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。
复制链接
扫一扫
分享
社区描述
VBA(Visual Basic for Applications)是Visual Basic的一种宏语言,是在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章