フレームExcel印刷


  fs.vbs



  
Dim FileSystem

' ******************************************************
' 初期化
' ******************************************************
Function FsInit()

	If Not IsObject(FileSystem) Then
		Set FileSystem = CreateObject("Scripting.FileSystemObject")
	End If

End Function

' ******************************************************
' ファイルの読み込みオープン
' ******************************************************
Function FsReadOpen(strFileName)

	Call FsInit

	Set FsReadOpen = FileSystem.OpenTextFile(strFileName, 1)

End Function

' ******************************************************
' ファイルの書き込みオープン
' ******************************************************
Function FsWriteOpen(strFileName)

	Call FsInit

	Set FsWriteOpen = FileSystem.CreateTextFile(strFileName, 1)

End Function

' ******************************************************
' クローズ
' ******************************************************
Function FsClose(fp)

	fp.Close
	Set fp = Nothing

End Function

' ******************************************************
' EOF
' ******************************************************
Function FsEof(fp)

	FsEof = fp.AtEndOfStream

End Function

' ******************************************************
' ファイルの複写
' ******************************************************
Function FsCopy(strFrom, strTo)

	Call FsInit

	FileSystem.CopyFile strFrom, strTo, True

End Function

' ******************************************************
' テンポラリディレクトリの取得
' ******************************************************
Function FsGetTmp()

	Call FsInit

	FsGetTmp = FileSystem.GetSpecialFolder(2)

End Function

' ******************************************************
' 存在チェック
' ******************************************************
Function FsExist(Spec, nType)

	Call FsInit
	
	Select Case nType
		Case 0  ' ファイル
			FsExist = FileSystem.FileExists(Spec)
		Case 1  ' ディレクトリ
			FsExist = FileSystem.FolderExists(Spec)
		Case 2  ' ドライブ
			FsExist = FileSystem.DriveExists(Spec)
	End Select

End Function

' ******************************************************
' ディレクトリ作成
' ******************************************************
Function FsMkDir(Spec)

	Call FsInit

	Dim i
	Dim strParent

	strParent = Spec

	On Error Resume Next
	FileSystem.CreateFolder Spec
	On Error GoTo 0
	If FsExist(Spec, 1) Then
		Exit Function
	End If
	strParent = FileSystem.GetParentFolderName(Spec)
	If strParent = "" Then
		Exit Function
	End If
	
	Do While Not FsExist(strParent, 1)
		
		strParent = FileSystem.GetParentFolderName(strParent)
		If strParent = "" Then
			Exit Do
		End If
		
		On Error Resume Next
		FileSystem.CreateFolder strParent
		On Error GoTo 0
	
		strParent = Spec
		On Error Resume Next
		FileSystem.CreateFolder strParent
		On Error GoTo 0
	
	Loop

End Function

' ******************************************************
' ディレクトリ削除
' ******************************************************
Function FsRmDir(Spec, Force)

	Call FsInit

	On Error Resume Next
	FileSystem.DeleteFolder Spec, Force
	On Error GoTo 0

End Function


' ******************************************************
' カレントディレクトリ取得
' ******************************************************
Function FsGetCurDir()

	Call FsInit

	FsGetCurDir = FileSystem.GetAbsolutePathName(".")

End Function

' ******************************************************
' 使用されていないドライブを取得
' ******************************************************
Function FsGetFreeDrive(nType)

	Call FsInit
	
	Dim i
	Dim TargetDrive

	If nType = 0 Then
		For i = &H44 To &H5A
			On Error Resume Next
			Set TargetDrive = FileSystem.GetDrive(Chr(i) & ":")
			If Err.Number <> 0 Then
				FsGetFreeDrive = Chr(i) & ":"
				Exit Function
			End If
		Next
	Else
		For i = &H5A To &H44 Step -1
			On Error Resume Next
			Set TargetDrive = FileSystem.GetDrive(Chr(i) & ":")
			If Err.Number <> 0 Then
				FsGetFreeDrive = Chr(i) & ":"
				Exit Function
			End If
		Next
	End If

End Function

' ******************************************************
' ファイルの削除
' ******************************************************
Function FsDeleteFile(TargetFile)

	Call FsInit

	Call FileSystem.DeleteFile(TargetFile, True)

End Function
  










  infoboard   管理者用   
このエントリーをはてなブックマークに追加





フリーフォントWEBサービス
SQLの窓WEBサービス

SQLの窓フリーソフト

素材

一般WEBツールリンク

SQLの窓

フリーソフト

JSライブラリ