使用Excel宏移动文件

时间:2018-12-26 05:32:05

标签: excel vba excel-vba

我希望我的csv能够运行命令,将文件从主目录位置移到Windows上的公共目录。

我尝试了各种语法,所有语法都带有= cmd前缀,用于执行命令。

=cmd|’move C:\document.docx C:\public\document.docx’!

这应该将文件移动到可通过Web访问的公共目录。但是,我无法检索它。我正在运行MacOS,因此无法在本地进行测试。目标盒是远程的。

2 个答案:

答案 0 :(得分:0)

CSV在功能excel格式中受限制(仅用于各种平台或使用其他语言编程的应用程序之间的集成) 您只能使用“ .xlsm或.xlsb”格式

我在另一个线程中找到了此代码

$ sudo pecl install -f libsodium
downloading libsodium-2.0.20.tgz ...
Starting to download libsodium-2.0.20.tgz (28,504 bytes)
.........done: 28,504 bytes
4 source files, building
running: phpize
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
building in /tmp/pear/temp/pear-build-rootsL5uMO/libsodium-2.0.20
running: /tmp/pear/temp/libsodium/configure --with-php-config=/usr/bin/php-config
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php/20160303 -I/usr/include/php/20160303/main -I/usr/include/php/20160303/TSRM -I/usr/include/php/20160303/Zend -I/usr/include/php/20160303/ext -I/usr/include/php/20160303/ext/date/lib
checking for PHP extension directory... /usr/lib/php/20160303
checking for PHP installed headers prefix... /usr/include/php/20160303
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... no
configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
checking for gawk... gawk
checking for sodium support... yes, shared
checking for pkg-config... no
checking for libsodium... configure: error: Please install libsodium - See https://github.com/jedisct1/libsodium
ERROR: `/tmp/pear/temp/libsodium/configure --with-php-config=/usr/bin/php-config' failed

您可以在此处找到合适的答案 “ stackoverflow.com/questions/38456928/move-files-from-one-folder-to-another”

答案 1 :(得分:0)

使用Name...AS语句

请参阅:https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/name-statement

Sub moveFile()
    dim oldname as string, newname as string
    oldname = "C:\document.docx"
    newname = "C:\public\document.docx"

    name oldname as newname
End Sub