• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Hi from the given code now i want to modify some functions. Since i am very new for coding please help me out with a solution.

prathi

New Member
Code:
Sub DDL変換_Click()
  
    Call ReplaceFromFile("C:\Users\PC533\Desktop\03_DDL変換ツール\INPUT\801_MKYT_GYOMBI.sql")
  
End Sub
Public Function ReplaceFromFile(FileName As String)
Dim FSO         As FileSystemObject 'ファイルシステムオブジェクト
Dim Txt         As TextStream       'テキストストリームオブジェクト
Dim buf_strTxt  As String           '読み込みバッファ
On Error GoTo Func_Err:
'オブジェクト作成
Set FSO = CreateObject("Scripting.FileSystemObject")
Set Txt = FSO.OpenTextFile(FileName, ForReading)
'全文読み込み
  buf_strTxt = Txt.ReadAll
  Txt.Close
  '元ファイルをリネームして、テンポラリファイル作成
  Name FileName As FileName & "_"
  '置換処理
   buf_strTxt = Replace(buf_strTxt, "NUMBER", "NUMERIC", , , vbBinaryCompare)
   buf_strTxt = Replace(buf_strTxt, "NVARCHAR2", "VARCHAR", , , vbBinaryCompare)
   buf_strTxt = Replace(buf_strTxt, "VARCHAR2", "VARCHAR", , , vbBinaryCompare)
   buf_strTxt = Replace(buf_strTxt, "CLOB", "TEXT", , , vbBinaryCompare)
  '書込み用テキストファイル作成
   Set Txt = FSO.CreateTextFile(FileName, True)
  '書込み
  Txt.Write buf_strTxt
  Txt.Close
  'テンポラリファイルを削除
  FSO.DeleteFile FileName & "_"
'終了処理
Func_Exit:
    Set Txt = Nothing
    Set FSO = Nothing
    Exit Function
Func_Err:
    MsgBox "Error Number : " & Err.Number & vbCrLf & Err.Description
    GoTo Func_Exit:
End Function




\\\
from the given code now i want to modify as, it shld automatically take mul I/Pfile from fldr﹠the resultant O/Pfile shld be stored destined fldr.
 
Last edited by a moderator:

Chihiro

Excel Ninja
Give description of what "I/Pfile" is and what "O/Pfile" is... not clear what you wish to do what this stands for, it isn't clear from your post exactly what you wish to do.

At any rate, you shouldn't modify the code at all. But use it in another routine that iterates over files in a given folder I'd imagine.
 
Top