Excell Automation (Selection)
Q1970
Member Posts: 34
Hi there.
I use Navision 4.00 SP3 and MS Office 2003.
I can't figure out how to access the "selection" property in Excell. To make matters simple, let's assume that I want to set bold fonts on the cells A7, B7 and C7. The Excell macro looks like this.
Range("A7:C7").Select
Selection.Font.Bold = True
My variables look like this
ExcellApp Automation 'Microsoft Excel 11.0 Object Library'.Application
ExcellWorkbook Automation 'Microsoft Excel 11.0 Object Library'.Workbook
ExcellWorksheet Automation 'Microsoft Excel 11.0 Object Library'.Worksheet
My code looks like this
CREATE(ExcellApp);
ExcellApp.Visible(TRUE);
ExcellWorkbook := ExcellApp.Workbooks._Open(FileName);
ExcellWorksheet := ExcellWorkbook.Worksheets.Item(SheetName);
ExcellWorksheet.Activate;
ExcellWorksheet.Range('A7:C7').Select;
And now, at the moment of truth, I hit the wall. I have tried
ExcellApp.Selection.Font.Bold(1);
and
ExcellApp.Selection.Font.Bold := True;
but apparantly I am doing something very very wrong. In both instances, I get the same error message "The return value should be used for this function". The cursor places itself rightafter "Selection".
How big a fool am I, and what should I have done?
Thanks in advance.
/Q
I use Navision 4.00 SP3 and MS Office 2003.
I can't figure out how to access the "selection" property in Excell. To make matters simple, let's assume that I want to set bold fonts on the cells A7, B7 and C7. The Excell macro looks like this.
Range("A7:C7").Select
Selection.Font.Bold = True
My variables look like this
ExcellApp Automation 'Microsoft Excel 11.0 Object Library'.Application
ExcellWorkbook Automation 'Microsoft Excel 11.0 Object Library'.Workbook
ExcellWorksheet Automation 'Microsoft Excel 11.0 Object Library'.Worksheet
My code looks like this
CREATE(ExcellApp);
ExcellApp.Visible(TRUE);
ExcellWorkbook := ExcellApp.Workbooks._Open(FileName);
ExcellWorksheet := ExcellWorkbook.Worksheets.Item(SheetName);
ExcellWorksheet.Activate;
ExcellWorksheet.Range('A7:C7').Select;
And now, at the moment of truth, I hit the wall. I have tried
ExcellApp.Selection.Font.Bold(1);
and
ExcellApp.Selection.Font.Bold := True;
but apparantly I am doing something very very wrong. In both instances, I get the same error message "The return value should be used for this function". The cursor places itself rightafter "Selection".
How big a fool am I, and what should I have done?
Thanks in advance.
/Q
0
Answers
-
It never fails, does it. As soon as the post is away, someone waltzes in an shows you how.
ExcellWorksheet.Range('A7:C7').Font.Bold(1);
Does the trick.
I'll get my coat. :oops:
Have a good one, everybody!0 -
Yup never fails. And ditto.0
-
Hi everybody,
Let me open this old topic for some time, because I've got the same problem. The problem is that I can't use Range here, becasue I need to input some text into the Shape object in Excel.
Example from excel is:ActiveSheet.Shapes("Text 2").Select Selection.Characters.Text = "aaa"In NAV there is no acess to Shapes (as we usually do with the Range) and Shape object itselft does not have methods/properties for changing its value.
I hope the solution is easy, but can anyone help with it?0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions