- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Get and set row height and font size of Excel worksheet cells
Hi everybody!
Lately I've been trying to create external Excel sheets with iLogic, with the Excel API/object. Filling in cells is not an issue, but I'm not able to change the font and/or font size of cells/ranges in the Excel sheet.
First I tried to retrieve the current Font size with this function:
Logger.Info("Fontsize " & ExcelSH.Range("A1:A1").Font.Size)But this doesn't work, iLogic returns the error: "Object reference not set to an instance of an object.".
Also tried to retrieve the rowheight by this snippet:
Logger.Info("Row height " & ExcelSH.Rows.Item(1).RowHeight)But this also returns the above mentioned error.
I'm doubting if it's in anyway possible to change the formatting of cells in Excel through iLogic. Maybe some of you could help me with this?
Thanks!
Product Design Suite 2024
Inventor 2024 (v 28.20.27200.0000), Vault Basic 2024
Fusion 360
HP Workstation Z4
Intel Xeon 3.4GHz
32GB RAM
Windows 10 Professional (64bit)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I don't work with iLogic, but this sounds very similar to the errors that VBA code generates when using a object that hasn't been properly assigned. I'm guessing that either "Logger" or "ExcelSH" does not actually refer to an object. In VBA this would look like:
Dim ExcelSH as Worksheet
Set ExcelSH = New Worksheet' Are you missing this line?
-Kerry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Could you supply the full code accessing the worksheet?
The error "Object reference not set to an instance of an object.". Suggests that your not able to access an object so the next question is which object? You will need to check the work sheet then the range and so on.
Or if this helped you, please, click (like)
Regards
Alan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Oh oh oh, I feel so dumb!!
There's no solution for that... The problem was the order of lines of code. I called the ExcelSH.Rows.Item(1).RowHeight property before the ExcelSH object was even created. So I reversed the order of commands and now it works.
Sorry I vaporized the precious time of you all...
Product Design Suite 2024
Inventor 2024 (v 28.20.27200.0000), Vault Basic 2024
Fusion 360
HP Workstation Z4
Intel Xeon 3.4GHz
32GB RAM
Windows 10 Professional (64bit)