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 = 100
I 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.