OOobbs2/188
質問
こんにちは。 マクロの作り方がわるいのか、「Writerのマクロをバッチファイルから起動した際、線がずれてしまう」という現象が発生します。 原因がわからず困っています。 なにか知っている情報がありましたら教えてください。 <Version>
WndowsXP Professional Version2002 Service Pack3 OpenOffice.org 3.0.0 OOO300m9 Build:9358 <マクロの仕様>
・文字列の置換を行なう ・プロパティのユーザー部分の情報を置き換える。 ・変更を保存後、PDFファイルにする。 <現象>
変更前のファイル(odt)の中に線が入っていた場合、 線が四隅のどこかに寄ってしまう。 <マクロの中身>
以下長いですが、記載します。 REM ***** BASIC ***** sub Main ( cFile ) rem ---------------------------------------------------------------------- rem define variables dim document as object dim dispatcher as object rem ---------------------------------------------------------------------- rem get access to the document rem document = ThisComponent.CurrentController.Frame cURL = ConvertToURL( cFile ) ' Open the document. Just blindly assume that the document ' is of a type that OOo will correctly recognize and open ' without specifying an import filter. document = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, _ Array(MakePropertyValue( "Hidden", True ),)) dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") rem フッタのProperties.Title取得---------------------------------------------------------------------- GlobalScope.BasicLibraries.LoadLibrary("Tools") oUrl = FileNameOutOfPath(cFile) oUrl = Left( oUrl , Len( oUrl ) - 4 ) rem カーソルを一番上に---------------------------------------------------------------------- dispatcher.executeDispatch(document.getCurrentController().getFrame(), ".uno:GoToStartOfDoc", "", 0, Array()) rem SampleAAの書き換え---------------------------------------------------------------------- dim args2(18) as new com.sun.star.beans.PropertyValue args2(0).Name = "SearchItem.StyleFamily" args2(0).Value = 2 args2(1).Name = "SearchItem.CellType" args2(1).Value = 0 args2(2).Name = "SearchItem.RowDirection" args2(2).Value = true args2(3).Name = "SearchItem.AllTables" args2(3).Value = false args2(4).Name = "SearchItem.Backward" args2(4).Value = false args2(5).Name = "SearchItem.Pattern" args2(5).Value = false args2(6).Name = "SearchItem.Content" args2(6).Value = false args2(7).Name = "SearchItem.AsianOptions" args2(7).Value = false args2(8).Name = "SearchItem.AlgorithmType" args2(8).Value = 0 args2(9).Name = "SearchItem.SearchFlags" args2(9).Value = 65536 args2(10).Name = "SearchItem.SearchString" args2(10).Value = "SampleAA" args2(11).Name = "SearchItem.ReplaceString" args2(11).Value = "SampleBB" args2(12).Name = "SearchItem.Locale" args2(12).Value = 255 args2(13).Name = "SearchItem.ChangedChars" args2(13).Value = 2 args2(14).Name = "SearchItem.DeletedChars" args2(14).Value = 2 args2(15).Name = "SearchItem.InsertedChars" args2(15).Value = 2 args2(16).Name = "SearchItem.TransliterateFlags" args2(16).Value = 1280 args2(17).Name = "SearchItem.Command" args2(17).Value = 3 args2(18).Name = "Quiet" args2(18).Value = true dispatcher.executeDispatch(document.getCurrentController().getFrame(), ".uno:ExecuteSearch", "", 0, args2()) rem カーソルを一番上に戻す---------------------------------------------------------------------- dispatcher.executeDispatch(document.getCurrentController().getFrame(), ".uno:GoToStartOfDoc", "", 0, Array()) rem SampleCCの書き換え---------------------------------------------------------------------- dim args14(18) as new com.sun.star.beans.PropertyValue args14(0).Name = "SearchItem.StyleFamily" args14(0).Value = 2 args14(1).Name = "SearchItem.CellType" args14(1).Value = 0 args14(2).Name = "SearchItem.RowDirection" args14(2).Value = true args14(3).Name = "SearchItem.AllTables" args14(3).Value = false args14(4).Name = "SearchItem.Backward" args14(4).Value = false args14(5).Name = "SearchItem.Pattern" args14(5).Value = false args14(6).Name = "SearchItem.Content" args14(6).Value = false args14(7).Name = "SearchItem.AsianOptions" args14(7).Value = false args14(8).Name = "SearchItem.AlgorithmType" args14(8).Value = 0 args14(9).Name = "SearchItem.SearchFlags" args14(9).Value = 65536 args14(10).Name = "SearchItem.SearchString" args14(10).Value = "SampleCC" args14(11).Name = "SearchItem.ReplaceString" args14(11).Value = "SampleDD" args14(12).Name = "SearchItem.Locale" args14(12).Value = 255 args14(13).Name = "SearchItem.ChangedChars" args14(13).Value = 2 args14(14).Name = "SearchItem.DeletedChars" args14(14).Value = 2 args14(15).Name = "SearchItem.InsertedChars" args14(15).Value = 2 args14(16).Name = "SearchItem.TransliterateFlags" args14(16).Value = 1280 args14(17).Name = "SearchItem.Command" args14(17).Value = 3 args14(18).Name = "Quiet" args14(18).Value = true dispatcher.executeDispatch(document.getCurrentController().getFrame(), ".uno:ExecuteSearch", "", 0, args14()) rem ---------------------------------------------------------------------- dispatcher.executeDispatch(document.getCurrentController().getFrame(), ".uno:GoToStartOfDoc", "", 0, Array()) rem フッタの変更---------------------------------------------------------------------- dim args16(17) as new com.sun.star.beans.PropertyValue args16(0).Name = "Properties.UseUserData" args16(0).Value = true args16(1).Name = "Properties.DeleteUserData" args16(1).Value = false args16(2).Name = "Properties.Title" args16(2).Value = oUrl args16(3).Name = "Properties.Subject" args16(3).Value = "" args16(4).Name = "Properties.KeyWords" args16(4).Value = "" args16(5).Name = "Properties.Description" args16(5).Value = "" args16(6).Name = "Properties.AutoReload" args16(6).Value = false args16(7).Name = "Properties.AutoReloadTime" args16(7).Value = 0 args16(8).Name = "Properties.AutoReloadURL" args16(8).Value = "" args16(9).Name = "Properties.AutoReloadFrame" args16(9).Value = "" args16(10).Name = "Properties.Field1Title" args16(10).Value = "Info 3" args16(11).Name = "Properties.Field2Title" args16(11).Value = "Info 4" args16(12).Name = "Properties.Field3Title" args16(12).Value = "test1" args16(13).Name = "Properties.Field4Title" args16(13).Value = "test2" args16(14).Name = "Properties.Field1" args16(14).Value = "" args16(15).Name = "Properties.Field2" args16(15).Value = "" args16(16).Name = "Properties.Field3" args16(16).Value = "test3" args16(17).Name = "Properties.Field4" args16(17).Value = "test4" dispatcher.executeDispatch(document.getCurrentController().getFrame(), ".uno:SetDocumentProperties", "", 0, args16()) rem 目次・検索の更新---------------------------------------------------------------------- rem dispatcher.executeDispatch(document.getCurrentController().getFrame(), ".uno:UpdateCurIndex", "", 0, Array()) rem 保存---------------------------------------------------------------------- dispatcher.executeDispatch(document.getCurrentController().getFrame(), ".uno:Save", "", 0, Array()) rem PDF出力----------------------------------------------- SaveAsPDF( cFile ) document.close(True) end sub ' Save document as an Acrobat PDF file. Sub SaveAsPDF( cFile ) cURL = ConvertToURL( cFile ) ' Open the document. Just blindly assume that the document ' is of a type that OOo will correctly recognize and open ' without specifying an import filter. oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, _ Array(MakePropertyValue( "Hidden", True ),)) cFile = Left( cFile, Len( cFile ) - 4 ) + ".pdf" cURL = ConvertToURL( cFile ) ' Save the document using a filter. oDoc.storeToURL( cURL, Array(_ MakePropertyValue( "FilterName", "writer_pdf_Export" ),) oDoc.close( True ) End Sub Function MakePropertyValue( Optional cName As String, Optional uValue ) _ As com.sun.star.beans.PropertyValue Dim oPropertyValue As New com.sun.star.beans.PropertyValue If Not IsMissing( cName ) Then oPropertyValue.Name = cName EndIf If Not IsMissing( uValue ) Then oPropertyValue.Value = uValue EndIf MakePropertyValue() = oPropertyValue End Function 回答
感想,コメント,メモ
|