Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Visio使用VBA以编程方式设置页面方向_Vba_Visio - Fatal编程技术网

Visio使用VBA以编程方式设置页面方向

Visio使用VBA以编程方式设置页面方向,vba,visio,Vba,Visio,我需要使用VBA以可编程的方式将页面方向属性更改为“横向”值。目前,我正在使用以下代码: Application.ActivePage.PageSheet.CellsU(“PrintPageOrientation”)。公式=2 但这只适用于打印机,不适用于我正在更改的页面 我一直在寻找合适的细胞,但我没有任何成功 谢谢您的帮助。只需设置页面的高度和宽度即可。没有用于横向/纵向的单元格 约翰。。。Visio MVP我知道这是一个老问题,但对于任何正在寻找答案的人来说: 更改Visio中的Print

我需要使用VBA以可编程的方式将页面方向属性更改为“横向”值。目前,我正在使用以下代码:

Application.ActivePage.PageSheet.CellsU(“PrintPageOrientation”)。公式=2

但这只适用于打印机,不适用于我正在更改的页面

我一直在寻找合适的细胞,但我没有任何成功


谢谢您的帮助。

只需设置页面的高度和宽度即可。没有用于横向/纵向的单元格


约翰。。。Visio MVP

我知道这是一个老问题,但对于任何正在寻找答案的人来说: 更改Visio中的
PrintPageOrientation
单元格会更改文档中页面的方向,而不仅仅是用于打印

对于变量名为
vzpVisioPage
的页面对象,以下行将设置横向方向:

vzpVisioPage.PageSheet.CellsSRC(visSectionObject, visRowPrintProperties, _
    visPrintPropertiesPageOrientation).FormulaForceU = "2"
要制作合法大小的页面,请使用以下行:

vzpVisioPage.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageWidth).FormulaU = "14 in"
vzpVisioPage.PageSheet.CellsSRC(visSectionObject, visRowPage, visPageHeight).FormulaU = "16.5 in"

基于上面SmrtGrunt的解决方案,我创建了一个C#示例:

///以上包含在
使用Visio=Microsoft.Office.Interop.Visio;
///在私人领域
私有Visio.Page活动页面;
///建造师以上
ActivePage=Globals.ThisAddIn.Application.ActivePage;
/// 
///将当前打开的文档设置为横向(如果尚未设置)
/// 
公共空间景观()
{
var orientation=ActivePage.PageSheet.CellsSRC[(短)Visio.VisSectionIndexes.visSectionObject,
(短)Visio.VisRowIndexes.visRowPrintProperties,
(短)Visio.ViscellIndexs.visPrintPropertiesPageOrientation].FormulaU;
//如果方向标志未设置为“横向”
如果(方向!=((int)viso.tagVisCellVals.visPPOLandscape.ToString())
{
//景观
ActivePage.PageSheet.CellsSRC[(短)viso.visSectionIndexs.visSectionObject,
(短)Visio.VisRowIndexes.visRowPrintProperties,
(短)Visio.viscellIndexes.visPrintPropertiesPageOrientation].FormulaU=((int)Visio.tagVisCellVals.visPPOLandscape).ToString();
var currentWidth=ActivePage.PageSheet.cellsrc[(短)Visio.vissectionindex.visSectionObject,
(短)Visio.VisRowIndexs.visRowPage,(短)Visio.VisCellIndexs.visPageWidth].FormulaU;
var currentHeight=ActivePage.PageSheet.CellsSRC[(短)Visio.VisSectionIndexes.visSectionObject,
(短)Visio.VisRowIndexs.visRowPage,(短)Visio.VisCellIndexs.visPageHeight].FormulaU;
ActivePage.PageSheet.CellsSRC[(短)viso.visSectionIndexs.visSectionObject,
(短)Visio.VisRowIndexs.visRowPage,(短)Visio.VisCellIndexs.visPageWidth].FormulaU=currentHeight;
ActivePage.PageSheet.CellsSRC[(短)viso.visSectionIndexs.visSectionObject,
(短)Visio.VisRowIndexs.visRowPage,(短)Visio.VisCellIndexs.visPageHeight].FormulaU=currentWidth;
}
}

这完全正确,感谢您的发布!请注意,它只会更改属性,您需要自己手动设置新的高度和宽度。