Forum: สอบถามปัญหา Notes ทางด้านพัฒนาโปรแกรม (Note Client) |
Tags1: | Created on Nov 13, 2010, 7:52 PM by 9notes/9Notes|Topic Responses: 7 |
&action=openDocument&documentId=1FBA |
ตายตรงบรรทัดนี้ครับ path ของเครื่องที่ run ไม่ได้มีอยู่ครับ จึงไม่สามารถสร้างไฟล์ภายใต้ path นี้ได้ครับ
filename = "C:\マイ ドキュメント\Export\" & viewname & ".csv"
ผมปรับโค๊ดนิดหน่อยเป็นการ call function CreateValidDir ให้ทำการสร้าง folder ให้อัตโนมัตถ้าไม่ได้มี path นี้อยู่ก็ให้สร้างใหม่ตามนี้ครับ
filepath = CreateValidDir ("C:\マイ ドキュメント\Export\")
filename = filepath & viewname & ".csv"
Function CreateValidDir (installDirectory As String)
' *********************************************************************************************
'Copyright (c) 1997 Lotus Development Corp., all rights reserved
'
' Name - CreateDir
' Purpose - Creates a valid installation directory if needed or validates the existing one
' Arguments:
' installDirectory - directory to be used for installation
' *********************************************************************************************
CreateValidDir = 0
' Always remember the Current directory and Switch back to it before exit:
Dim CurrentDirectory As String
CurrentDirectory = Curdir ()
' does this directory already exist?
On Error Goto NotExistError
Chdir(installDirectory)
'if we got here, directory exists
Goto GetOut
'if we got here, it does not exist, so create it
NotExistError:
Err = 0
Resume NextLabel
NextLabel:
On Error Goto MkDirError
Print "Destination directory not found. Program will automatic create " & installDirectory & " "
Mkdir(installDirectory)
Chdir(installDirectory)
Goto GetOut
'Cannot create the directory
MkDirError:
CreateValidDir = Err
Goto GetOut
GetOut:
Chdir CurrentDirectory
Exit Function
End Function |
|