使用简短代码便可实现word批量转pdf

本方法可在系统文件夹中,将文件夹里的word文档批量转换成pdf格式,且无需借助工具。

代码如下:

'Convert .doc or .docx to .pdf files via Send To menu
Set fso = CreateObject("Scripting.FileSystemObject")
For i= 0 To WScript.Arguments.Count -1
   docPath = WScript.Arguments(i)
   docPath = fso.GetAbsolutePathName(docPath)
   If LCase(Right(docPath, 4)) = ".doc" Or LCase(Right(docPath, 5)) = ".docx" Then
      Set objWord = CreateObject("Word.Application")
      pdfPath = fso.GetParentFolderName(docPath) & "\" & _
    fso.GetBaseName(docpath) & ".pdf"
      objWord.Visible = False
      Set objDoc = objWord.documents.open(docPath)
      objDoc.saveas pdfPath, 17
      objDoc.Close
      objWord.Quit   
   End If   
Next

粘贴本段代码至记事本中,如下所示:

将文件另存为.vbs的格式进行保存:

点击保存,即可得到脚本文件:

将该脚本复制到需要转换的word文档所在文件夹中,可将word文档拖入到脚本中,稍等片刻,便可得到转换后的pdf文档。

转换后的格式如下:

  • 15
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简短实现的C语言贪吃蛇代码: ```c #include <stdio.h> #include <stdlib.h> #include <conio.h> #include <windows.h> #define WIDTH 40 #define HEIGHT 20 int x, y, fx, fy, score; int snake[WIDTH * HEIGHT][2]; int len = 1; void initSnake() { x = WIDTH / 2; y = HEIGHT / 2; snake[0][0] = x; snake[0][1] = y; } void initFood() { srand(time(NULL)); fx = rand() % WIDTH; fy = rand() % HEIGHT; } void draw() { system("cls"); for (int i = 0; i < HEIGHT; i++) { for (int j = 0; j < WIDTH; j++) { if (i == 0 || i == HEIGHT - 1 || j == 0 || j == WIDTH - 1) printf("#"); else if (i == y && j == x) printf("O"); else if (i == fy && j == fx) printf("@"); else { int flag = 0; for (int k = 0; k < len; k++) { if (snake[k][0] == j && snake[k][1] == i) { printf("o"); flag = 1; break; } } if (!flag) printf(" "); } } printf("\n"); } printf("Score: %d\n", score); } void move() { int rx = x, ry = y; if (_kbhit()) { switch (_getch()) { case 'w': y--; break; case 'a': x--; break; case 's': y++; break; case 'd': x++; break; } } if (x == fx && y == fy) { len++; score += 10; initFood(); } for (int i = 0; i < len; i++) { int tempx = snake[i][0], tempy = snake[i][1]; snake[i][0] = rx; snake[i][1] = ry; rx = tempx; ry = tempy; } } int main() { initSnake(); initFood(); while (1) { draw(); move(); if (x < 1 || x >= WIDTH - 1 || y < 1 || y >= HEIGHT - 1) { printf("Game Over\n"); break; } for (int i = 1; i < len; i++) { if (x == snake[i][0] && y == snake[i][1]) { printf("Game Over\n"); goto end; } } Sleep(200); } end: return 0; } ``` 希望对你有所帮助!

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值