2022-12-13 03:09:32
利用word的宏批量把word转换为pdf

我不会用宏,提供以下方法:
步骤:
1. 把所有需转换的word文档放在一下文件夹里
2. ctrl+a 选择全部文档 (如果太多可能转换起来会很慢)
3. 右击->选择 [转换成adobe pdf]
4. 会提示你另存为
前提要装pdf程式,acrobat8 或 acrobat9都可以,网上有下载。 求采纳啊
用vba实现word 文件的批量打印?

sub 批量对word操作()
' a.公共部分的代码
application.screenupdating = false '冻结屏幕,以防屏幕抖动,这句好像没作用,窗口仍然会颤抖
dim mydialog as filedialog, getstr(1 to 1000) as string '1000是工作时的文档上限数,可因需修改,不知没有限制的命令怎样写?
on error resume next
set mydialog = application.filedialog(msofiledialogfilepicker)
with mydialog
.title = "请选择要处理的文档(可多选)"
.filters.clear '过滤掉筛选器中的所有文件类型,然后现在下面用filters.add加上word类型
.filters.add "所有word文件", "*.doc", 1
.allowmultiselect = true 'true表示允许多选,如果需要单选,请用false
i = 1
if .show = -1 then
for each stiselecteditem in .selecteditems
getstr(i) = stiselecteditem
i = i + 1
next
i = i - 1
end if
application.screenupdating = false
for j = 1 to i step 1
set doc = documents.open(filename:=getstr(j), visible:=true)
windows(getstr(j)).activate
' b可以替换的宏
' 以下是处理格式所录制的宏,可根据所需录制
application.run macroname:="单个文件默认打印" '运行名为"单个文件默认打印"的宏,宏命令见后面
' 以上可以换成是你自己录制的宏,
'其中application.run macroname:="单个文件默认打印"'运行名为"单个文件默认打印"的宏,根据需要录制,自行命名
' c公共部分的代码
activedocument.save '保存
activewindow.close '退出
next
application.screenupdating = true
end with
msgbox "操作完成,请查看!!", 64, "提示"
'application.quit '关闭并退出word
end sub
sub 单个文件默认打印()
'
' 下面是按默认的打印录制的宏,你可以自己录制。
'
'
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 sub
vba将一个word表格中的内容复制到另外一个word的表...

'打开后焦点发生了转移,activedocument已经指向刚打开的文件了
'改为
sub macro1()
dim mydoc
'on error resume next
with activedocument.tables(1).cell(row:=1, column:=3).range
set mydoc = word.application.documents.open("e:\1.docx")
.delete
.insertafter text:=mydoc.tables(2).cell(row:=1, column:=2)
end with
end sub
'(
insertafter text:=mydoc.tables(2).cell(row:=1, column:=2)这行代码中,你确定表2存在吗?我测试时只建一个表,所以改为tables(1).
)
'也可以这样控制焦点
sub macro1()
dim mydoc
'on error resume next
set mydoc = word.application.documents.open("e:\1.docx", , , , , , , , , , , vbhide)
with activedocument.tables(1).cell(row:=1, column:=3).range
.delete
.insertafter text:=mydoc.tables(2).cell(row:=1, column:=2)
end with
end sub
'至于为什么多出一个换行符我还没想明白
用vba让excel和word自动另存为

如果是操作过程中自动备份,这个功能word和excel自带。
如果是为了操作完毕,关掉文档时,自动将当前文档复制一份到e盘。这个有两种方式。
1、用vba方式
2、调用bat方式
假设你的文件都在c:\my document\目录中,并且你希望把这些文件备份在e:\备份中,你的excel安装在默认目录下
1。先打开记事本,输入以下语句:
start/w "c:\program files\microsoft office\office\excel.exe" %1
xcopy/m/d/y/s "c:\my document\*.xls" e:\备份
保存为.bat文件后退出。
2。在桌面为这个文件建个快捷方式,然后右击,选择属性->程序->运行->最小化
以后要打开excel就用这个快捷方式,它会自动打开excel,并且在你退出excel之后自动备份你刚才修改过的excel文件,没有修改的不备份。
3这种备份方法同样适用于word等其它的程序,而且是全自动的。
解释一下这两句命令:
start是启动一个程序,加上/w是等待的意思,也就是说等这个程序关闭才执行下面的语句。
xcopy的/m参数是指拷贝具有存档属性的文件,几乎所有的程序都会在修改文件后给文件加上存档属性,此文件在拷贝后会去掉存档属性。
xcopy的/d参数是指拷贝的源文件比目标文件的日期要新。
xcopy的/y是指复盖文件不提示。
xcopy的/s参数是指拷贝子目录。
用vba批量处理word 中的表格:将表格内容调整为上下,...

你把
for each otable in odoc.tables
otable.range.font.name = "黑体" ' 改变表格字体为“黑体”
otable.range.font.size = 10.5 ' 改变表格字号为12磅
next
改为:
for each otable in odoc.tables
otable.autofitbehavior (wdautofitwindow) '根据窗口调整内容
otable.range.paragraphformat.alignment = wdalignparagraphcenter '水平居中
otable.range.cells.verticalalignment = wdcellalignverticalcenter '垂直居中
next