How to declare a DonNet System.Object variable in NAV2013R2?

kirkostas
Member Posts: 127
I want to use the Excel's Workbook Method SaveAs because I want to change the Save as Type and save my workbook in Formatted Text (Space delimited) (*.prn).
But this method has many parameters of type System.Object and I can't find this assembly and I am using NAV variables instead. Text, boollean,integer but it doesn't work and in return I get this error message:
A dotnet variable has not been instantiated. Attempting to call Microsoft.Office.Interop.Excel.Workbook.SaveAs in Table Excel Buffer: SaveAs
Does this means that the method is not initiated properly with the correct variables? But how can I declare a System.Object variable in NAV?
This is the code I am using:
But this method has many parameters of type System.Object and I can't find this assembly and I am using NAV variables instead. Text, boollean,integer but it doesn't work and in return I get this error message:
A dotnet variable has not been instantiated. Attempting to call Microsoft.Office.Interop.Excel.Workbook.SaveAs in Table Excel Buffer: SaveAs
Does this means that the method is not initiated properly with the correct variables? But how can I declare a System.Object variable in NAV?
This is the code I am using:
XlWrkBk.SaveAs( FileName,FileFormat,Password,WriteResPassword,ReadOnlyRecommended,CreateBackup, XLSAVEASACCESSMODE,ConflictResolution,AddToMru,TextCodepage,TextVisualLayout,Local);
kirkostas™
0
Comments
-
Hi kirkostas,
Below two link will be help to you.
_Workbook.SaveAs Method : http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel._workbook.saveas%28v=office.14%29.aspx
Problem with Workbook.SaveAs :
http://social.msdn.microsoft.com/Forums ... m=exceldev
I copied the sample code from Workbook.Saveas topicxlWorkBook.SaveAs("C:\\MyExcelTestTest.xlsx", System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value, false, false, Excel.XlSaveAsAccessMode.xlShared, false, false, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value);
Best Regards,
YukonMake Simple & Easy0 -
I am familiar with those links. But how can I pass a System.Object variable from NAV? Also I searched for System.Reflection but it didn't gave me the System.Reflection.Missing.Value !
Do you use this code in Nav or its just an example of how it will looks like in C#?
I tried to use the following variables but no luck!Name DataType Subtype Length XlFileFormat DotNet Microsoft.Office.Interop.Excel.XlFileFormat.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' XlSaveAsAccessMode1 DotNet Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' XlSaveConflictResolution DotNet Microsoft.Office.Interop.Excel.XlSaveConflictResolution.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' XlTextVisualLayoutType DotNet Microsoft.Office.Interop.Excel.XlTextVisualLayoutType.'Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
kirkostas™0 -
Hi Kirkostas,
Did you find a solution to your problem? I have a similar problem. I need to call a DotNet Method but I need to pass some System.Object parameters. These are optional parameters, but I guess optional parameters are not supported in NAV. Therefore I have to explicitly pass these "empty" parameters anyhow.
Much appreciated...0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions