公司网站上经常要发新闻,撰稿人在写稿子的时候,把新闻图片也插到了WORD文档里,发布新闻的人在网页上发新闻时,只能把文字部分复制到输入框里,图片是不会自动复制上去的,就需要把文档里的图片取出来再上传。
只要把这个文档另存为“网页”,比如存成名字为“我的新闻”的网页,存好后,会有一个 HTM 文件和一个同名的文件夹,在这个文件夹里就有这个文档中用到的所有图片,而且这些图片是原始大小,不会有任何的质量损失。
这就是技术吧
如何取出存在WORD文档里的图片
EXCEL 中跨工作表表格汇总
总公司要求子公司都上报几种同样的报表,再把这些报表汇表生成汇总表,比如资产负债表等。
我的思路是,在一个 EXCEL 文件中,做多个工作表,每个工作表表示一个子公司,在工作表里相同的位置放同样格式的表格。
先做好基础数据表:
增加汇总表工作表,把表格样子做好:
在需要汇总的格子上“插入批注”:
批注内容写成“SUM”:
然后到“开发工具”里打开“ Visual Basic”编辑器,在“汇总表”里写事件:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | Private Sub Worksheet_Activate() Dim iRow As Integer Dim iCol As Integer iRow = 10 iCol = 10 Dim iAmount As Double For i = 1 To iRow For j = 1 To iCol If Cells(i, j).NoteText = "SUM" Then iAmount = 0 For isheet = 1 To Sheets.Count - 1 If Sheets(isheet).Cells(i, j) <> "" And Left(Sheets(isheet).Cells(i, j), 1) <> "-" Then On Error Resume Next iAmount = iAmount + CDbl(Sheets(isheet).Cells(i, j)) If Err.Number <> 0 Then MsgBox ("Sheet " + CStr(isheet) + ":" + CStr(i) + "," + CStr(j) + ":" + Sheets(isheet).Cells(i, j)) On Error GoTo 0 End If Next isheet If iAmount <> 0 Then Cells(i, j) = iAmount Else Cells(i, j) = "" End If End If Next j Next i End Sub |
写好后,再回到 EXCEL 里,当工作表切换到“汇总表”时,所有标记“SUM”批注的格子就会自动汇总。
Delphi 程序对 Windows VISTA 的支持
以前一直在 WIN XP /2003 下编程,现在有客户使用 VISTA 系统,运行程序的时候报错。我的程序用到了注册表,还是对 HKLM 进行读写,VISTA 的安全机制肯定是不让了,别人的软件在遇到这个问题的时候都有一个 WINDOWS 的安全提示,询问是否以管理员身份运行,我的程序就什么提示都没有,直接报错。后来在网上查到了解决办法,让我的程序也支持 VISTA 了。
操作步骤:
1.建立 res 文件
建立一个文本文件,名字可以自己起,我这里叫:UAC.manifest,内容:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="requireAdministrator"/> </requestedPrivileges> </security> </trustInfo> </assembly>
建立文本文件,名为 UAC.rc,内容:
1 24 UAC.manifest
编译成 uac.res 文件,运行:
brcc32 uac.rc -fouac.res
2.在代码中引入
打开项目文件,加入
{$R uac.res}3.编译程序
这时程序就支持 VISTA 了,在运行的时候,会弹出 WINDOWS 的提示框,询问用户是否允许以管理员身份运行。
Windows Vista 系统下安装 BDS2006 Update 2
在 Windows Vista 系统下安装 BDS 2006 的 Update 2 时,可能会出现下面的错误:“Setup cannot continue. This is Update 2 setup for Borland Developer Studio 2006 <Edition> Edition. Please cancel this and install Edition of Update 2.”
解决办法:
在开始菜单附件中,找到“命令提示符”,右键,“以管理员身份运行”,假如我把我的安装包放到了我的桌面上,我的用户名叫 mike,那我就键入“cd \Users\mike\Desktop”,然后“msiexec /update bds2006_en_arch_upd2.msp”,就可以了。
这个问题是由于 Vista 的安全机制引起的。
C# 中子窗体最大化的问题
在 C# 中做 MDI 程序的时候,子窗体经常是被定义成最大化状态,在子窗体的属性里,把 WindowState 设置成 Maximized,然后在主窗体中用 frmChild.Show() 来显示,代码如下:
1 2 3 | frmChild fc = new frmChild(); fc.MdiParent = this; fc.Show(); |
运行的时候,会发现一个问题,子窗口并没有真正的最大化,而是窗口外框是最大化的,里面的控件还都是原来的位置,没有达到最大化的效果。
解决办法:在子窗体属性里把 WindowState 设置成 Normal,在代码中去设置这个属性值就可以了,代码如下:
1 2 3 4 | frmChild fc = new frmChild(); fc.MdiParent = this; fc.WindowState = FormWindowState.Maximized; fc.Show(); |
这样,运行就正常了。
在 VS2005 和 VS2008 中都是这样。
让 WordPress 用 SMTP 方式发邮件
装好 WordPress 后,默认是用 PHP 的 mail 来发送邮件,一般情况下,都不太符合我们的要求,还是想用自己的邮箱来发,那就要用到 SMTP 了。
有两个文件要改,都是在 wp-includes 目录下,class-phpmailer.php 和 pluggable.php。
先改 class-phpmailer.php
把几个变量的值填上,有 $From、$FromName、$Sender、$Mailer、$Host、$SMTPAuth、$Username、$Password。
然后再改 pluggable.php,找到 wp_mail() 函数中 $phpmailer->IsMail(),改成 $phpmailer->IsSMTP() 就可以了。
WM6.1 关闭短信对话模式的方法
在刷了 WM6.1 后,短信使用的是对话模式,最开始一用,感觉很好,用着用着,随着给同一个人发短信的条数的增多,每次打开短信内容的时候,会把以前的消息都列出来,很慢,所以还是改成以前的模式比较好。
修改注册表就可以实现:
在注册表里找到
[HKEY_CURRENT_USER\Software\Microsoft\Inbox\Settings]
新建 项[OEM],然后在 OEM 下新建 DWORD 键值,名为:SMSInboxThreadingDisabled,值为 1
重启短信功能或重开机就行了
下载 Windows Server 2008 和 SQL Server 2008 试用
早就听说微软发布了 Windows Server 2008 和 SQL Server 2008,一直没有时间去下载过来试试。这几天有闲了,在网上搜了一下,找到了比较好的版本进行下载。
先贴上下载地址:
SQL Server 2008 企业版下载:
http://www.verycd.com/groups/0202/325706.topic
Windows Server 2008 下载:
http://www.verycd.com/groups/0202/246304.topic
SQL Server 2008 在安装的时候,是已经填好序列号的,只要继续就可以了,安好就是企业版。如果要安装开发版的话,只要在序列号那里更改为开发版的序列号,就可以在 Windows XP 下安装了。
Windows Server 2008 安装的时候不需要输入序列号,但是还不能激活,下载的页面里有人给出了序列号,我也没有激活成功,用 hot8.cn 出的 vista 激活程序也不起作用,就暂时放下了。
在 Windows 下只启动一个 emacs 进程
下载的 emacs 包里,有两个用得着的可执行文件:runemacs.exe、emacsclientw.exe。平时运行 runemacs.exe 就可以启动 emacs 了,但每运行一次都打开一个新的窗口,文件一多,屏幕上就会很乱。为了让每次都在已经打开的 emacs 中新开一个 buffer 来处理文件,需要运行 emacs 的 server 模式。
1.设置环境变量
新建注册表项:HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs,新建字符串键 HOME,值设置为你自己的 HOME 目录就可以,如 E:\MyDoc
2.编辑 .emacs 文件
在 emacs 里 C-x C-f ~/.emacs,然后写入:
(server-start) (add-hook 'kill-emacs-hook (lambda() (if (file-exists-p "~/.emacs.d/server/server") (delete-file "~/.emacs.d/server/server"))))
3.创建 myemacs.vbs,这是最后我们调用的文件
Set fso = Wscript.CreateObject("Scripting.FileSystemObject") Set WshShell = WScript.CreateObject("WScript.Shell") dim runcmd if fso.FileExists(WshShell.ExpandEnvironmentStrings("E:\MyDoc\.emacs.d\server\server")) then runcmd = "d:\emacs-22.2\bin\emacsclientw.exe" else runcmd = "d:\emacs-22.2\bin\runemacs.exe" end if if WScript.Arguments.Count > 0 then runcmd = runcmd & " """ & WScript.Arguments.Item(0) & """" end if WshShell.run runcmd set WshShell = nothing set fso = nothing
上面 emacs 的 bin 和 E:\MyDoc 目录要根据自己的情况修改。
4.把 myemacs.vbs 的快捷方式放到发送菜单里,或者以自己的方式运行 “myemacs.vbs 文件名” 就可以了。
运行之前最好重新启动一下。
VMware ESX Server 3.5 出现 pegasus 什么什么的错误
刚装好的服务器,启动的时候出现这个错误:
Processing /var/pegasus/vmware/install_queue/1 [FAILED]
ERROR:log –/var/pegasus/vmware/install_queus/1.log
Processing /var/pegasus/vmware/install_queue/1 [FAILED]
ERROR:log –/var/pegasus/vmware/install_queus/1.log
到网上搜一搜,搜到了这个文章:
http://communities.vmware.com/message/914939#914939
Edit the roleauth-schema compiler directive to include the VMware_Identity class definition using
nano /var/pegasus/vmware/install_queue/3_files/mofs/root/PG_Interop/roleauth-schema.mof
Add the bolded line above the pre-existing member directive.
#pragma include (“VMware_Identity.mof”)
#pragma include (“VMware_IdentityMemberOfCollection.mof”)It also needs to be added in the standard cimv2 path.
nano /var/pegasus/vmware/install_queue/3_files/mofs/root/cimv2/roleauth-schema.mof
#pragma include (“VMware_Identity.mof”)
#pragma include (“VMware_IdentityMemberOfCollection.mof”)Copy the missing file from the stardard cimv2 path to the shared path.
cp /var/pegasus/vmware/install_queue/3_files/mofs/root/cimv2/VMware_Identity.mof /var/pegasus/vmware/install_queue/3_files/mofs/root/PG_Interop/
Stop and start the service with these commands.
/etc/init.d/pegasus stop
/etc/init.d/pegasus startOnce the scripts completes the install_queues will be empty and the service will start much more quickly.
按上面说明修改,其中的 3_files 要用 1_files 代替,之后,不出错了。





