CopyFile Command Altered by Hide MS-DOS Extension OptionLast reviewed: February 5, 1998Article ID: Q134808 |
The information in this article applies to:
SYMPTOMSWhen you use the WordBasic command, CopyFile, the copy of the file does not have an extension. As a result, the copied file loses its association with Microsoft Word and becomes a generic Windows 95 file. The following code results in this problem:
Sub MAIN CopyFile "c:\storage\test.doc", "c:\temp" End Sub CAUSEThis problem occurs when the "Hide MS-DOS file extensions for file types that are registered" is checked in Windows Explorer. (To locate this option, in Windows Explorer, click Options on the View menu.)
STATUSMicrosoft has confirmed this to be a problem in Microsoft Word for Windows 95 version 7.0. This problem was corrected in Word version 7.0a for Windows 95.
RESOLUTIONTo work around this problem, use one of the following methods to preserve the copied file's association with Microsoft Word. Method 1. Make sure the "Hide MS-DOS file extensions for file types that are registered" option in Windows Explorer is not checked.Method 2. Use the Declare command to make a CopyFileA call to Kernel32.dll. To do this, use the following macro: NOTE: The sample assumes that you have a Microsoft Word document called "Test.doc" located in the C:\Storage folder. Declare Function CopyFileA Lib "kernel32"(a$ As String, b$ As String, n As Integer) As Integer Sub MAIN x = CopyFileA("c:\storage\test.doc", "c:\temp\test.doc ", 3) End Sub NOTE: Using a number greater than 0 in the above example will not overwrite an existing file. The file specified as the destination remains the same. However, if 0 is used, as in the example below, the destination file will be overwritten by the specified file if it exists in the specified directory. Declare Function CopyFileA Lib "kernel32"(a$ As String, b$ As String, n As Integer) As Integer Sub MAIN x = CopyFileA("a:\test.doc", "c:\test.doc ", 0) End SubWARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
|
KBCategory: kbusage buglist7.0 fixlist7.0a
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |