Home > Software engineering >  Under Windows 7 vba generated file, file name can't generate, see detailed content
Under Windows 7 vba generated file, file name can't generate, see detailed content

Time:10-03

To excel vba code, by calling the GetSaveAsFileName to create a new file, the code is as follows:
FileName="Trans." & amp; Org & amp; ". "& amp; Tmpdate & amp; "DAT" 'filename result is Trans. 0503.20141116. DAT
Filename=Application. GetSaveAsFileName (Filename, fileFilter:="Text Files (*. *), *. TXT")
Before this code under the Windows xp system running normally, but the unit equipment update for Windows 7, found the updated file can be generated, but the file name without generating, empty,
After the test, if in the file with "dot" (". ") cannot be used as the default file name, for example:
Filename=Application. GetSaveAsFileName (" abcdefg ", fileFilter:="Text Files (*. *), *. TXT") 'can run, file called abgdefg
Filename=Application. GetSaveAsFileName (ab. CD. Ef. "g", fileFilter:="Text Files (*. *), *. TXT") 'can run, but the file is called an empty

Please action ah, thank you very much,

CodePudding user response:

"Text Files (*. *), *. TXT")=="" Text Files (*.txt), *.txt")

So you can (only need the TXT anyway, so in advance plus good) :
Filename=Application. GetSaveAsFilename (" ab. CD. Ef. G.t xt, fileFilter:="Text Files (*.txt), *. TXT")

CodePudding user response:

reference 1st floor Topc008 response:
"Text Files (*. *), *. TXT")=="" Text Files (*.txt), *.txt")

So you can (only need the TXT anyway, so in advance plus good) :
Filename=Application. GetSaveAsFilename (" ab. CD. Ef. G.t xt, fileFilter:="Text Files (*.txt), *. TXT")


I tried, no effect, my name is Trans. 0503.20141116. DAT, although the content is the text structure, but, as required by the company in the file name will appear more "points", and the suffix must be. DAT, if the file name is "Trans050320141116DAT" there is no issue, so it should be some thing, how to do? Need to translate?

CodePudding user response:

Filename=Application. GetSaveAsFilename (ab. CD. Ef. G.d "at", fileFilter:="dat Files (*. Dat), *. Dat")

With * *. Dat. TXT?

CodePudding user response:

Also enough wonderful work ha ha, the company's requirements, with an underscore is better than with a little,
  •  Tags:  
  • VBA
  • Related