Boa Tarde.

Estou tentando Importar uma Page Setup de um arquivo, e setá-lo no meu arquivo atual .

Não consegui nenhum objeto no Developer's help do VBA que me faça carregar e setar uma page setup. Pelas minhas andanças pela internet, entendi que o VBA não suporta carregar e setar uma page setup. Posso estar enganado.

Entretanto baixei do AUIForum um rotina em VBA aonde o autor diz que ele importa e seta a page setup. Copiando e colando não consegui fazê-la funiconár, tentei modificar alguns parâmetros mas meus conhecimentos sobre VBA ainda são escassos.

A rotina em VBA é essa:

Dim strAppPath As String
Dim strFileName As String
Dim strFilePath As String
Dim strPSSetup As String
Dim strMSSetup As String
Dim objPCdwt As AcadPlotConfiguration
Dim objPC As AcadPlotConfiguration
Dim objLayout As AcadLayout
Dim dbxdoc As Object 'AxDbDocument
Dim strTempName As String
Dim fso As Scripting.FileSystemObject
Dim fsoFile As Scripting.File

'Setup: customize here for your installation
strAppPath = ThisDrawing.Application.Preferences.Files.TemplateDwgPath
strFileName = "_Engineering.dwt" 'must be a dwg, not dwt
strFilePath = strAppPath & "\" & strFileName
strMSSetup = "ModelPlot" 'name of model space setup
strPSSetup = "GS_B_size_5si" 'name of paper space setup

Set fso = CreateObject("Scripting.FileSystemObject")
'delete all PlotConfigurations
For Each objPC In ThisDrawing.PlotConfigurations
objPC.Delete
Next objPC
'template filename to get the PlotConfiguration's from
'check for stored template name
strFilePath = GetSetting(strAppName, "ImportPageSetups", "DefaultFile", strFilePath)
strFileName = fso.GetFileName(strFilePath)
'open the template
' We're using ObjectDBX so that the user doesn't see another window and
' for speed and so that it doesn't matter whether they have SDI set to 1 or 0.
'check for dwt, ObjectDbx can only open dwg's
If fso.GetExtensionName(strFilePath) = "dwt" Then
'copy template to temp folder as dwg
strTempName = ThisDrawing.Application.Preferences.Files.TempFilePath & fso.GetBaseName(strFilePath) & ".dwg"
fso.CopyFile strFilePath, strTempName, True
strFilePath = strTempName
End If
Set dbxdoc = AcadApplication.GetInterfaceObject("ObjectDBX.AxDbDocument")
dbxdoc.Open strFilePath
'copy the plot configs from the template
For Each objPCdwt In dbxdoc.PlotConfigurations
Set objPC = ThisDrawing.PlotConfigurations.Add(objPCdwt.Name, objPCdwt.ModelType)
objPC.CopyFrom objPCdwt
Next objPCdwt
'set a current "Page Setup" for the layout
Set objPC = ThisDrawing.PlotConfigurations.Item(strPSSetup)
For Each objLayout In ThisDrawing.Layouts
If objLayout.ModelType = True Then
objLayout.CopyFrom ThisDrawing.PlotConfigurations.Item(strMSSetup)
Else
objLayout.CopyFrom objPC
End If
Next objLayout
'cleanup
Set objPC = Nothing
Set objPCdwt = Nothing
Set dbxdoc = Nothing
Set objLayout = Nothing
'delete temp file if exists
If Not strTempName = vbNullString Then fso.DeleteFile strTempName
Set fso = Nothing
ThisDrawing.Utility.Prompt vbCr & "Command: Page Setups imported from " & strFileName & vbCr

End Sub


O autor comenta que ele utiliza um "objectDBX". Esta rotina faz parte do Exc aqui do AUGI aqui está o link para download:

http://www.augi.com/exchange/submiss...geSetupsND.zip


Bom Srs. Essa é minha duvida. Para solucioná-la também tentei usando os comandos do prompt do autocad via Thisdrawing.SendCommand - So que o pagesetup sempre abre uma janela pop up, e uma vez que estou automatizando processos não queria que o usuário precisasse escolher uma pagesetup.

Obrigado

Att,

Gabriel Barros