不需要WordApp.printout打印全部,可以选择打印
。
。
。
。
。
Set Word = WordApp.Documents.Open(current_file)WordApp.PrintOut Pages:="3"Word.CloseWordApp.quitSet WordApp = NothingSet Word = Nothing。
。
。
。
经过试验,程序打印的还是全部,WordApp.PrintOut Pages:="3"这个语句没起打印第三页的作用! Sub BreakOnPage()' Used to set criteria for moving through the document by page.Application.Browser.Target = wdBrowsePageFor i = 1 To ActiveDocument.BuiltInDocumentProperties("Number of Pages")'Select and copy the text to the clipboardActiveDocument.Bookmarks("\page").Range.Copy' Open new document to paste the content of the clipboard into.Documents.AddSelection.Paste' Removes the break that is copied at the end of the page, if any.Selection.TypeBackspaceChangeFileOpenDirectory "C:\"DocNum = DocNum + 1ActiveDocument.SaveAs FileName:="test_" & DocNum & ".doc"ActiveDocument.Close' Move the selection to the next page in the documentApplication.Browser.NextNext iActiveDocument.Close savechanges:=wdDoNotSaveChangesEnd Sub
Word打印如何编码页数
第一步 首先找到Word里的宏按钮,如图。
然后,会弹出宏查看窗口,起一个名字然后选择创建,如图。
第二步 在弹出的宏录制窗口内输入宏代码,然后保存,如图。
宏代码如下:Sub PrintCopies() ' ' Macro1 Macro ' ' Dim i As Long Dim lngStart Dim lngCount lngCount = InputBox(“Please enter the number of copies you want to print”, “Please enter the number of copies you want to print”, 1) If lngCount = “” Then Exit Sub End If lngStart = InputBox(“Enter the starting number you want to print”, “Enter the starting number you want to print”, 1) If lngStart = “” Then Exit Sub End If For i = lngStart To lngCount If i Selection.TypeText Text:=”000″ & i& Application.PrintOut FileName:=”", Range:=wdPrintAllDocument, Item:= _ wdPrintDocumentContent, Copies:=1, Pages:=”", PageType:=wdPrintAllPages, _ ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _ False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 End If If (i >= 10) And (i Selection.TypeText Text:=”00″ & i& Application.PrintOut FileName:=”", Range:=wdPrintAllDocument, Item:= _ wdPrintDocumentContent, Copies:=1, Pages:=”", PageType:=wdPrintAllPages, _ ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _ False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 End If If (i >= 100) And (i Selection.TypeText Text:=”0″ & i& Application.PrintOut FileName:=”", Range:=wdPrintAllDocument, Item:= _ wdPrintDocumentContent, Copies:=1, Pages:=”", PageType:=wdPrintAllPages, _ ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _ False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 End If If (i >= 1000) And (i Selection.TypeText Text:=i Application.PrintOut FileName:=”", Range:=wdPrintAllDocument, Item:= _ wdPrintDocumentContent, Copies:=1, Pages:=”", PageType:=wdPrintAllPages, _ ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _ False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 End If Selection.TypeBackspace Selection.TypeBackspace Selection.TypeBackspace Selection.TypeBackspace Next End Sub 第三步 把输入光标放在你想要添加打印份数编号的地方,然后运行宏,会弹出如下窗口,第一个窗口是输入打印份数,第二个窗口是输入起始数字,如图。
如何在word文档打印时自动编号?
1. 首先找到Word里的宏按钮2. 弹出宏查看窗口,起一个名字然后选择创建3. 在弹出的宏录制窗口内输入宏代码,然后保存,宏代码见下方。
4. 把输入光标放在你想要添加打印份数编号的地方,然后运行宏,会弹出如下窗口,第一个窗口是输入打印份数,第二个窗口是输入起始数字 宏代码如下: Sub PrintCopies() Macro1 Macro Dim i As Long Dim lngStart Dim lngCount lngCount = InputBox(“Please enter the number of copies you want to print”, “Please enter the number of copies you want to print”, 1) If lngCount = “” Then Exit Sub End If lngStart = InputBox(“Enter the starting number you want to print”, “Enter the starting number you want to print”, 1) If lngStart = “” Then Exit Sub End If For i = lngStart To lngCount If i Selection.TypeText Text:=”000″ & i& Application.PrintOut FileName:=”", Range:=wdPrintAllDocument, Item:= _ wdPrintDocumentContent, Copies:=1, Pages:=”", PageType:=wdPrintAllPages, _ ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _ False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 End If If (i >= 10) And (i Selection.TypeText Text:=”00″ & i& Application.PrintOut FileName:=”", Range:=wdPrintAllDocument, Item:= _ wdPrintDocumentContent, Copies:=1, Pages:=”", PageType:=wdPrintAllPages, _ ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _ False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 End If If (i >= 100) And (i Selection.TypeText Text:=”0″ & i& Application.PrintOut FileName:=”", Range:=wdPrintAllDocument, Item:= _ wdPrintDocumentContent, Copies:=1, Pages:=”", PageType:=wdPrintAllPages, _ ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _ False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 End If If (i >= 1000) And (i Selection.TypeText Text:=i Application.PrintOut FileName:=”", Range:=wdPrintAllDocument, Item:= _ wdPrintDocumentContent, Copies:=1, Pages:=”", PageType:=wdPrintAllPages, _ ManualDuplexPrint:=False, Collate:=True, Background:=True, PrintToFile:= _ False, PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _ PrintZoomPaperHeight:=0 End If Selection.TypeBackspace Selection.TypeBackspace Selection.TypeBackspace Selection.TypeBackspace Next End Sub
Application.Printout()打印什么情况下会调用?
session对象:session对象主要用于保存用户的各种信息,知道它的生命周期(一般是900S)超时或者被人为释放为止 可以通过session对象来判断此用户是否是合法用户 在服务器上通过session来区分每一个上网用户 session对象属于javax.servlet.http.HttpSession接口的实例化对象 session属于HTTP协议范畴之内的对象,所以只有唯一的一个http包下有此接口,没有任何继承关系 用户只要一连接服务器则立刻分配一个session给用户session的主要方法:服务器上通过session来分别不同的用户-->sessionID:任何连接到服务器上的用户,服务器都会为之分配唯一一个不会重复的sessionID sessionID是由服务器同意管理的,人为不能控制 方法:session.getId() sessionID的长度为32位判断是不是新的session Public boolean isNew(),判断当前的session是否是新建立的sessionsession的属性设置 设置属性setAttribute() 取得属性getAttribute() 删除属性removeAttribute() 通过session能够对用户是否登陆做出验证★用户注销:让用户的session失效 若用户的session失效,则在session所保留的全部操作也会消失 方法:Public Void invalidate()使session失效(需手工操作) 若session长时间不被使用,也会自动失效得到session的创建时间 方法:Public long getCreationTime(),此方法返回一个long类型,通过Date类可以取得一个完整的时间取得用户最后一次操作的时间 方法:Public long getLastAccessedTime() 用户在线时间=session最后一次操作时间-session创建时间
贴吧里涅盘怎么打出来?我在地址栏里粘贴了这个代码jav
import com.jacob.activeX.ActiveXComponent; import com.jacob.com.Dispatch; import com.jacob.com.Variant; /** * @author XuMing Li * * @version 1.00, 2007-4-9 * */ public class D2P { private ActiveXComponent wordCom = null; private Object wordDoc = null; private final Variant False = new Variant(false); private final Variant True = new Variant(true); /** * 打开word文档 * * @param filePath * word文档 * @return 返回word文档对象 */ public boolean openWord(String filePath) { //建立ActiveX部件 wordCom = new ActiveXComponent( "Word.Application "); try { //返回wrdCom.Documents的Dispatch Dispatch wrdDocs = wordCom.getProperty( "Documents ").toDispatch(); //调用wrdCom.Documents.Open方法打开指定的word文档,返回wordDoc wordDoc = Dispatch.invoke(wrdDocs, "Open ", Dispatch.Method, new Object[] { filePath }, new int[1]).toDispatch(); return true; } catch (Exception ex) { ex.printStackTrace(); } return false; } /** * 关闭word文档 */ public void closeWord() { //关闭word文件 wordCom.invoke( "Quit ", new Variant[] {}); } /** * * 将word文档打印为PS文件后,使用Distiller将PS文件转换为PDF文件 * * * @param sourceFilePath * 源文件路径 * * @param destinPSFilePath * 首先生成的PS文件路径 * * @param destinPDFFilePath * 生成PDF文件路径 */ public void docToPDF(String sourceFilePath, String destinPSFilePath, String destinPDFFilePath) { if (!openWord(sourceFilePath)) { closeWord(); return; } //建立Adobe Distiller的com对象 ActiveXComponent distiller = new ActiveXComponent( "PDFDistiller.PDFDistiller.1 "); try { //设置当前使用的打印机,我的Adobe Distiller打印机名字为 "Adobe PDF " wordCom.setProperty( "ActivePrinter ", new Variant( "Adobe PDF ")); //设置printout的参数,将word文档打印为postscript文档。
目前只使用了前5个参数,如果要使用更多的话可以参考MSDN的office开发相关api //是否在后台运行 Variant Background = False; //是否追加打印 Variant Append = False; //打印所有文档 int wdPrintAllDocument = 0; Variant Range = new Variant(wdPrintAllDocument); //输出的postscript文件的路径 Variant OutputFileName = new Variant(destinPSFilePath); Dispatch.callN((Dispatch) wordDoc, "PrintOut ", new Variant[] { Background, Append, Range, OutputFileName }); System.out.println( "由word文档打印为ps文档成功! "); //调用Distiller对象的FileToPDF方法所用的参数,详细内容参考Distiller Api手册 //作为输入的ps文档路径 Variant inputPostScriptFilePath = new Variant(destinPSFilePath); //作为输出的pdf文档的路径 Variant outputPDFFilePath = new Variant(destinPDFFilePath); //定义FileToPDF方法要使用adobe pdf设置文件的路径,在这里没有赋值表示并不使用pdf配置文件 Variant PDFOption = new Variant( " "); //调用FileToPDF方法将ps文档转换为pdf文档 Dispatch.callN(distiller, "FileToPDF ", new Variant[] { inputPostScriptFilePath, outputPDFFilePath, PDFOption }); System.out.println( "由ps文档转换为pdf文档成功! "); } catch (Exception ex) { ex.printStackTrace(); } finally { closeWord(); } } public static void main(String[] argv) { D2P d2p = new D2P(); // d2p.openWord( "c:/12.doc "); // d2p.callWordMacro( "c:/12.docc ", "MyWordMacro ", // new String[] { "这是调用word宏的测试程序 " }); d2p.docToPDF( "d:/12.doc ", "c:/1p.ps ", "c:/1p.pdf "); } }
VB中用什么代码打印文件啊,语句怎么写啊,
VB中的几种打印方法 1. 采用Visual Basic 提供的简单打印函数PrintForm 方法。
应用程序窗体的PrintForm 方法时,Visual Basic 把窗体的位图送到当前打印机。
该方法的优点在于它几乎不需要任何编程,但也有很大缺陷。
最为突出的是当低分辨率图形在高分辨率打印机上打印时,其结果令人无法满意,会产生锯齿。
下面代码将在打印机上打印窗体。
Private Sub Command1_Click() ' 用PrintForm 打印 Me.PrintForm ' 打印窗体的可见区域 End Sub 2. 用Printer 对象进行高分辨率输出。
但要想产生复杂的打印输出,编程较为烦琐。
Printer 对象代表系统缺省的打印机,Printer 对象支持许多由窗体和图形框所支持的属性和方法,三种对象都有画线和画方框。
应用程序可用以下代码在Printer 对象上画出一平方英寸的方框。
它离左上角二英寸。
注意:打印机以twips 来测量距离。
每英寸有1440 个twips。
Printer.Line(2 *1440,2 *1440) -Step(1440,1440), ,B 打印机、从窗体和图形框都有Circle、PaintPicture、Print、Pset、TextHeight、TextWidth 方法。
使用这些方法,应用程序可以为打印机生成高分辨率输出。
打印文本直接用Print 方法,见下列代码: Printer.Print "Hello,China ComputerWorld!" ' 打印字符串 Printer 对象还有一些窗体和图形框都没有方法: NewPage 告诉打印机,程序对当前输出页的发送已经结束,Printer 对象应开始新的一页。
EndDoc 告诉VB,程序创建文档结束,VB 应将它发送到物理打印机上打印。
KillDoc 取消当前打印作业。
应用程序应该终止由EndDoc 和KillDoc 所设定的每个打印作业。
Zoom 属性用于定义打印输出的缩放因子。
Copies 属性用于定义打印的副本数目。
3. 采用直接将数据传送打印机的方法进行打印输出。
有两种方法将数据送往打印机。
第一种是用Print #方法,就像将数据写入一个文件一样。
另一种方法写端口,但不是送文本,而是送特定的PCL 语言,PCL 表示打印控制语言,它是一种特殊语言,用转义代码来控制打印机的具体动作。
因为此方法太烦琐,本文不做太多介绍。
4. 如果你在编程时用到了RichTextBox 控制,那么你可以使用该控件的SelPrint 方法来打印,使用非常简单。
下面一段代码即用RichTextBox 控件的SelPrint 方法来完成打印。
Private Sub Command3_Click() 'SelPrint 方法CommonDialog1.Flags=cdlPDReturnDC +cdlPDNoPageNums If RTF1.SelLength = 0 Then 'RTF1 为窗体的RichTextBox 控制 CommonDialog1.Flags = CommonDialog1.Flags +cdlPDAllPages Else CommonDialog1.Flags = CommonDialog1.Flags +cdlPDSelection End If CommonDialog1.CancelError = True On Error Resume Next CommonDialog1.ShowPrinter If Err.Number = cdlCancel Then Exit Sub If Err.Number 0 Then Beep MsgBox "Error printing file." &vbCrLf +Err.Description, vbOKOnly +vbExclamation, “Printing Error!" Exit Sub End If Printer.Print "" RTF1.SelPrint CommonDialog1.hDC ' 打印RTF1 控件的可见区域End Sub 上面代码先进行打进设置,再进行打印。
如果不需要设置,采用下面代码更为简单: RTF1.SelPrint Printer.hDC ' 打印RTF1 控件的可见区域 5. 可以在VB 中调用Word 97 提供的OLE 自动化服务,利用Word 97 强大的打印功能来完成VB 打印,笔者认为这是最令人满意的方法。
下面代码说明VB 如何与Word 集成。
Private Sub Command4_Click() ' 调用Word 打印Dim objWord As ObjectConst CLASSOBJECT = "Word.Application"On Error GoTo objErrorSet objWord = CreateObject(CLASSOBJECT)objWord.Visible = TrueobjWord.Documents.AddWith objWord.ActiveDocument.Paragraphs.Last.Range.Bold = False.ActiveDocument.Paragraphs.Last.Range.Font.Size =20.ActiveDocument.Paragraphs.Last.Range.Font.Name ="黑体".ActiveDocument.Paragraphs.Last.Range.Font.ColorIndex==4.ActiveDocument.Paragraphs.Last.Range.Text ="我是计算机世界读者!" End WithClipboard.ClearClipboard.SetText "通过剪切板向WORD 传送数据!" objWord.Selection.Paste objWord.PrintPreview = True ' 预览方式 'objWord.PrintOut' 执行打印 'objWord.Quit' 退出WordExit SubobjError:If Err 429 ThenMsgBox Str $(Err) &Error $Set objWord = Nothing ' 不能创建Word 对象则退出Exit SubElse Resume NextEnd IfEnd Sub 6. 用VC 编制DLL 模块完成打印。
在VB 中调用该模块,用混合编程方法进行打印输出。
因涉及VC 编程比较烦琐,这里不再讨论。
如何用java将pdf文件转换成word文件
需要用到插件jacob,自己去下载吧。
import com.jacob.activeX.ActiveXComponent; import com.jacob.com.ComThread; import com.jacob.com.Dispatch; import com.jacob.com.Variant; public class D2P { private ActiveXComponent wordCom = null; private Object wordDoc = null; private final Variant False = new Variant(false); private final Variant True = new Variant(true);/** *//** *//** *//*** 打开word文档** @param filePath* word文档* @return 返回word文档对象*/ public boolean openWord(String filePath) {//建立ActiveX部件 wordCom = new ActiveXComponent("Word.Application"); try {//返回wrdCom.Documents的Dispatch Dispatch wrdDocs = wordCom.getProperty("Documents").toDispatch();//调用wrdCom.Documents.Open方法打开指定的word文档,返回wordDoc wordDoc = Dispatch.invoke(wrdDocs, "Open", Dispatch.Method,new Object[] { filePath }, new int[1]).toDispatch(); return true; } catch (Exception ex) { ex.printStackTrace(); } return false; }/** *//** *//** *//*** 关闭word文档*/ public void closeWord() {//关闭word文件 wordCom.invoke("Quit", new Variant[] {}); }/** *//** *//** *//*** * 将word文档打印为PS文件后,使用Distiller将PS文件转换为PDF文件 *** @param sourceFilePath* 源文件路径 ** @param destinPSFilePath* 首先生成的PS文件路径 ** @param destinPDFFilePath* 生成PDF文件路径*/ public void docToPDF(String sourceFilePath, String destinPSFilePath,String destinPDFFilePath) { if (!openWord(sourceFilePath)) { closeWord(); return; }//建立Adobe Distiller的com对象 ActiveXComponent distiller = new ActiveXComponent("PDFDistiller.PDFDistiller.1"); try {//设置当前使用的打印机,我的Adobe Distiller打印机名字为"Adobe PDF" wordCom.setProperty("ActivePrinter", new Variant("MS Publisher Color Printer"));//设置printout的参数,将word文档打印为postscript文档。
目前只使用了前5个参数,如果要使用更多的话可以参考MSDN的office开发相关api//是否在后台运行 Variant Background = False;//是否追加打印 Variant Append = False;//打印所有文档 int wdPrintAllDocument = 0; Variant Range = new Variant(wdPrintAllDocument);//输出的postscript文件的路径 Variant OutputFileName = new Variant(destinPSFilePath); Dispatch.callN((Dispatch) wordDoc, "PrintOut", new Variant[] { Background, Append, Range, OutputFileName }); System.out.println("由word文档打印为ps文档成功!");//调用Distiller对象的FileToPDF方法所用的参数,详细内容参考Distiller Api手册//作为输入的ps文档路径 Variant inputPostScriptFilePath = new Variant(destinPSFilePath);//作为输出的pdf文档的路径 Variant outputPDFFilePath = new Variant(destinPDFFilePath);//定义FileToPDF方法要使用adobe pdf设置文件的路径,在这里没有赋值表示并不使用pdf配置文件 Variant PDFOption = new Variant("");//调用FileToPDF方法将ps文档转换为pdf文档 Dispatch.callN(distiller, "FileToPDF", new Variant[] { inputPostScriptFilePath, outputPDFFilePath, PDFOption }); System.out.println("由ps文档转换为pdf文档成功!"); } catch (Exception ex) { ex.printStackTrace(); } finally { closeWord(); wordCom=null;//释放在程序线程中引用的其它com,比如Adobe PDFDistiller ComThread.Release(); } } public static void main(String[] argv) { D2P d2p = new D2P(); d2p.docToPDF("d:/12.doc", "d:/1p.ps", "d:/1p.pdf");//这里是你建一个叫12.doc的word文档,生成的文档将在D盘下//1p.ps和1p.pdf(这是我们要的) } }
为何传不上照片了点击上传图片后没有任何反应,电脑左下总显示JAV ...
网络慢新浪系统慢电脑速度“慢”是主要问题。
网络越来越慢,新浪系统更是越来越慢,最后形成电脑慢,所以电脑速度慢多数情况是网络慢新浪系统慢和电脑慢兼而有之。
个人先排除自己的电脑问题,就会好得多,可以解决很多问题。
1、解决杂乱文件影响(解决恶意软件或插件)。
清理杂乱文件有三个方法,一是点网页上的“工具”,点“Internet选项(0)”,在新页面分别点“Cookies(I)”“删除文件(F)”“清除历史记录(H)”、最后“确定”;二是用“磁盘清理”,把鼠标指向程序——附件——系统工具——就显示出“磁盘清理”,所有的盘C、D、E等都要清理(主要是系统盘C)只要显示有文件的,都可以选择清理;三、如果你安有瑞星卡卡上网安全助手,点桌面“瑞星卡卡上网安全助手”,点“系统优化”,点“系统垃圾智能清除”,完毕后效果会更佳。
这三种方法,都可以清除正常浏览网页没有保存的所有文件,有用的系统文件和安装保存的文件不会被清理。
“整理磁盘碎片”也是改变电脑速度有效的方法把鼠标指向程序——附件——系统工具——就显示出“整理磁盘碎片”,主要是系统盘C, 很慢一般要一到两个小时甚至更多时间。
2、解决恶意流氓软件和恶意流氓插件影响。
恶意流氓软件和恶意流氓插件除少数是躲在自己下载的软件和安装的代码里面以外,主要是自己强行安装进电脑的,目的就是干扰操作系统,影响程序正常工作,用“磁盘清理”清不掉,杀毒软件发现不了,卡卡助手、奇虎360、雅虎助手等凡杀毒软件配置的助手,都可以用系统优化功能、系统防护功能等有效的清除恶意流氓软件和恶意流氓插件,只要经常清理,就可以保证电脑健康。
3、去掉添加多余空白面版影响(消除恶意代码) 点“设置首页内容”,把首页自己添加的不需要的模版全部去掉勾,“确定”就可以了。
也可以把所有模版全部去掉勾,恢复到初始, 正常后 再点“设置首页内容”,勾选自己需要的“模版”,“确定”即可。
4、杀毒软件和一键恢复 经常更新病毒库,升级杀毒,不要让病毒长期存留在电脑里,选择高级设置,发现病毒杀毒,杀不了删除文件、隔离、手动清除等配套杀毒,是电脑不受病毒侵害,保证健康最有效的手段。
但电脑遭遇病毒是难免的,为了减少重装系统的麻烦,一定要在装系统时装“一键恢复” 。
“一键恢复”就是操作系统备份,一般是装系统时设置,也就是确保操作系统健康。
在电脑遭遇病毒无法清除、程序错乱,速度特别慢等严重问题时,任何时候“一键恢复”,电脑就恢复到健康正常的系统,保证正常操作。
保持自己的电脑健康,只能是稍微好一点,解决正常操作显示等问题,不能解决根本性的系统慢的问题。
解决电脑问题,不要进行其它操作,多刷新几次不行,重新开机试试,否则只有等网络系统恢复正常了。
如何让WORD文档选择指定打印机呢?
1.打开要打印的WORD文档 。
2.点击菜单栏里的文件,然后点击“打印”。
3.在打印设置窗口里选择打印机的名称。
4.设置好页面的范围。
4.设置打印的份数。
5.设置打印的内容。
6.完成以上设置之后,点击“确定”,就可以完成WORD文档的打印了。
转载请注明出处51数据库 » word .printout() jav