Q&A

  • OLE로 워드를 호출하고 SAVE AS로 이름을 바꾸려고...
OLE로 워드를 메모리상에 호출하고 SAVE AS로 파일명을 바꾸려고...하는데요..

SAVE AS 할때 SAVEAS DOCUMENT라는 넘이 있던데요..

파일의 속성을 DOC에서 HTML로 자동 변환시키려구 하거든요..

단순히..CONVERT 시키는 데 파일명을 바꾸는 것으로 문제가 없는지요..

오피스2000에서 별 문제가 없다고 알고 있거든요..



VB코드로는 아래와 같거든요..



' open the DOC

goWordApp.Documents.Open filename:=<>



' save as HTML

goWordApp.ActiveDocument.SaveAs filename:=<>, FileFormat:=102, LockComments:=False, Password:="",

AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False,

EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False,

SaveFormsData:=False, SaveAsAOCELetter:=False



'get the whole html file in one hit

szHTML = GetFile(<>) '***** see below for fuction



' you then have the entire HTML source in a string,

which you can then search for whatever you like.

Once you are happy with your "edited" HTML, you then re-write the text file. Easy huh?!



'and dump out the new HTML file

iFile = FreeFile

Open <> For Output As #iFile

Print #iFile, szHTML

Close #iFile



Function GetFile(ByVal szFilename As String) As String

'

' returns the file as a string

'



On Error GoTo noFile



Dim iFile As Integer

Dim szTemp As String, szLine As String



szTemp = ""

iFile = FreeFile

Open szFilename For Input As #iFile



'loop through and open the file

While Not EOF(iFile)



Line Input #iFile, szLine

szTemp = szTemp & szLine & Chr$(13) & Chr$(10) Wend



Close iFile



GetFile = szTemp



Exit Function



noFile:

MsgBox "Can't find this file: " & szFilename

GetFile = ""



End Function



델파이로 바꾸려니...좀..애매한 부분이 있거든요...

소스좀 봐주세요

0  COMMENTS