CopyFile Command Altered by Hide MS-DOS Extension Option |
Q134808
When 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
This 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.)
Microsoft 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.
To work around this problem, use one of the following methods to preserve the copied file's association with Microsoft Word.
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 Sub
WARNING: 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.
Additional query words: 7.0 word95 copyfile copy file wordbasic word7 winword word basic macro example 6.0 2.0 2.0a-cd
Keywords : kbmacroexample
Issue type :
Technology : kbOSWin95 kbWordSearch kbOSWinSearch kbWord700Search kbZNotKeyword2 kbWord600 kbWord600a kbWord600c kbWord200 kbWord200a kbWord200b kbWord200c kbWord700 kbWord700a
|
Last Reviewed: June 1, 2001 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |