我正在编写一个复杂的VBA应用程序,它从一个工作簿导入数据,在导入时转换数据。 作为此导入过程的一部分,进行计算以获取某个单元格的.text值(并且不能将其更改为.value),但是这意味着如果源工作簿被缩小,则导入#### #### values,因为它是显示的内容。
我试图修改源工作簿的活动表中的.zoom设置为100%缩放。 下面使用的代码示例如下。
Dim SourcePath as String Dim SourceWorkbook as Object FilePath = Application.GetOpenFilename 'Opens dialogue for user to select source If FilePath <> "" Then 'Checks that the filepath is completed SourcePath = FilePath 'Stores the filepath for source End If Set SourceWorkbook = Workbooks.Open(SourcePath) SourceWorkbook.ActiveWorksheet.Zoom = 100我得到一个运行时错误91:对象变量或With块变量没有设置错误,所以我假设这里的逻辑很差。
任何人都可以建议一种使这项工作的方法吗? 谢谢你的期待。
I am writing a complex VBA app that imports data from one workbook, transforming the data as it imports. As part of this import process, a calculation is made that picks up the .text value of a certain cell (and this cannot be changed to .value), however this means if the source workbook is zoomed out, this imports ######## values, as that is what is displayed.
I am trying to modify the .zoom setting in the activesheet of the source workbook to be 100% zoom. An example of the code used is below.
Dim SourcePath as String Dim SourceWorkbook as Object FilePath = Application.GetOpenFilename 'Opens dialogue for user to select source If FilePath <> "" Then 'Checks that the filepath is completed SourcePath = FilePath 'Stores the filepath for source End If Set SourceWorkbook = Workbooks.Open(SourcePath) SourceWorkbook.ActiveWorksheet.Zoom = 100I am getting a run-time error 91: Object variable or With block variable not set error, so I am assuming the logic here is poor.
Can anybody suggest a way of making this work? Thanks in anticipation.
最满意答案
您可以使用以下代码
Sheets("Sheet Name").Select ActiveWindow.Zoom = 30 ' Zoom Set to 30%You can use the following code
Sheets("Sheet Name").Select ActiveWindow.Zoom = 30 ' Zoom Set to 30%更多推荐
发布评论