首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

vb怎么为excel表添加背景?

2012-01-23 
vb如何为excel表添加背景???现在用webbrowser打开excel表,如下:me.webbrowser.navigate d:\1.xls现在需

vb如何为excel表添加背景???
现在用webbrowser打开excel表,如下:
me.webbrowser.navigate "d:\1.xls"

现在需要在打开excel表的同时,给excel表填充一张背景图片,每次打开时的背景图片不固定。

网上找了好几种vba方法如下,在webbrowser中都不能用。
1、fill.userpicture 
2、setbackgroundpicture

这个要求必须在webbrowser中打开excel。

[解决办法]

web中使用的是OLE还是那个OWC控件呢
[解决办法]
Excel背景图?有效果图不?
[解决办法]
你先看看在excel里能加背景图不能
[解决办法]
可以添加那就录制宏啊,至少可以得到一些参考代码。

[解决办法]

探讨

引用:

可以添加那就录制宏啊,至少可以得到一些参考代码。


试过了 宏里面的代码是 ActiveSheet.SetBackgroundPicture Filename:=url

不知道在webbrowser下怎么用 直接用不了

[解决办法]
VB code
Option ExplicitPrivate xlsApp As Excel.Application      'Excel应用对象Private xlsBook As Excel.Workbook        'Excel工作薄对象Private xlsSheet As Excel.Worksheet      'Excel工作表对象Private Sub Command1_Click()    Dim bolP As Boolean    bolP = funOpenExcelFile(xlsApp, xlsBook, xlsSheet, "D:\1.xls", "Sheet1", "", False)    xlsSheet.SetBackgroundPicture FileName:="C:\Documents and Settings\All Users\Documents\My Pictures\示例图片\Water lilies.jpg"    bolP = funCloseExcelFile(xlsApp, xlsBook, xlsSheet, True)    Me.WebBrowser1.Navigate "d:\1.xls"End Sub'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'函数功能:打开指定的Excel文件'参数说明:xlsAPP:Excel应用对象'        :xlsWork:Excel工作薄对象'        :xlsSheet:Excel工作表对象'        :strExcelFile:Excel文件路径'        :strSheetName:工作表名'        :strPWD:密码'        :bolVisible:表的可见性'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Private Function funOpenExcelFile(ByRef xlsApp As Excel.Application, _                                 ByRef xlsWork As Excel.Workbook, _                                 ByRef xlsSheet As Excel.Worksheet, _                                 ByVal strExcelFile As String, _                                 ByVal strSheetName As String, _                                 ByVal strPWD As String, _                                 ByVal bolVisible As Boolean) As BooleanOn Error GoTo errFun    funOpenExcelFile = False    Set xlsApp = CreateObject("Excel.Application")    Set xlsWork = xlsApp.Workbooks.Open(strExcelFile, , False, , strPWD, strPWD)    Set xlsSheet = xlsBook.Worksheets(strSheetName)    xlsSheet.Activate    xlsApp.Visible = bolVisible    funOpenExcelFile = True    Exit FunctionerrFun:    funOpenExcelFile = FalseEnd Function'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%'函数功能:关闭指定的Excel文件'参数说明:xlsAPP:Excel应用对象'        :xlsWork:Excel工作薄对象'        :xlsSheet:Excel工作表对象'        :bolSave:是否保存'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Private Function funCloseExcelFile(ByRef xlsApp As Excel.Application, _                                 ByRef xlsWork As Excel.Workbook, _                                 ByRef xlsSheet As Excel.Worksheet, _                                 ByVal bolSave As Boolean) As BooleanOn Error GoTo errFun    If bolSave Then xlsBook.Save    Set xlsSheet = Nothing    xlsBook.Close    Set xlsBook = Nothing    Set xlsApp = Nothing    funCloseExcelFile = True    Exit FunctionerrFun:    funCloseExcelFile = FalseEnd Function 

热点排行