[NOT SOLVED] BStr retour from Filedialog, can not handled

bule
Member Posts: 7
I make a procedure to create a word document from Navision (3.70). After the document is maked, the document must be saved.
Therefore i create a filedialog with automation server ('Microsoft Office 11.0 Object Library') (Fd = FileDialog | FileDialogSelectedItems = DialogSelectedItems)
:shock: StrNm := FileDialogSelectedItems.Item(1);
The following error appears:
This datatype is not supported by C/Side. Only data from the following types can be used:
VT_VOID, VT_I2,VT_I4...etc....VT_BSTR AND VT_BOOL
StrnNm = Text with length 1024
The method gives a Bstr back, and this can not be handled by navision. But in codeunit 412 is also a Bstr used. So why can that work properly in codeunit 412 and not in this code? Here they used the Microsoft Common Dialog Control, version 6.0 (SP6), and this one gives also a Bstr back.
A BSTR (Basic string or binary string) is a string data type that is used by COM, Automation, and Interop functions. A BSTR is a composite data type that consists of a length prefix, a data string, and a terminator.
Who can help me??
Therefore i create a filedialog with automation server ('Microsoft Office 11.0 Object Library') (Fd = FileDialog | FileDialogSelectedItems = DialogSelectedItems)
Fd := FileDialog(2); WITH Fd DO BEGIN AllowMultiSelect := FALSE; InitialView := 1; InitialFileName := FilenameStr; Title := 'Navision'; END; Output := Fd.Show; IF Output =-1 THEN BEGIN FileDialogSelectedItems := Fd.SelectedItems; StrNm := FileDialogSelectedItems.Item(1); WrdDoc.SaveAs (StrNm); END;Everythings seems perfect, execpt the following statement gives an error.
:shock: StrNm := FileDialogSelectedItems.Item(1);
The following error appears:
This datatype is not supported by C/Side. Only data from the following types can be used:
VT_VOID, VT_I2,VT_I4...etc....VT_BSTR AND VT_BOOL
StrnNm = Text with length 1024
The method gives a Bstr back, and this can not be handled by navision. But in codeunit 412 is also a Bstr used. So why can that work properly in codeunit 412 and not in this code? Here they used the Microsoft Common Dialog Control, version 6.0 (SP6), and this one gives also a Bstr back.
-
from :
A BSTR (Basic string or binary string) is a string data type that is used by COM, Automation, and Interop functions. A BSTR is a composite data type that consists of a length prefix, a data string, and a terminator.
Who can help me??
0
Comments
-
Since you're not allowing multiple selected files, why not just do..
StrNm := Fd.Item;
Codeunit 412 uses an OCX though, so slightly different thing going on.0 -
Without the parameter it will not compilled in navison0
-
With little time spent on testing I haven't really come up with any results either. What is so wrong with using the Common Dialog Management codeunit to get your filepath + name?0
-
I call a word applicatie and add a document, during this time the user see the word applicatie build up and write the data from navision to the new document. When i use the common dialog, the user don't see it.
First the applicatie must be closed, saved or deactivated, then the dialog box is visible. The user is be asking to save the document, the wil follow the instruction, but an error appears after that, because the document is allready closed.
Whe using the filedialog box, the dialog appears while the document is still there. I have build in excel several years ago this procedure, and still today it is working very fine.0 -
So, back to your Word Problem.
Here the solution: U use the automation "Microsoft Office 11.0 Object Library') (Fd = FileDialo" Why this :?: In Word, there is also the Dialog Object and the methods of this object is also runable from Nav ;-)
Here an example ...if isclear(WordApp) then create(WordApp); WordApp.Visible(TRUE); WordDocuments := WordApp.Documents; WordDocument := WordDocuments.Add(); WordDocument.Activate; WordSelection := WordApp.Selection; WordSelection.TypeText := 'Here is some text'; WordDialogs := WordApp.Dialogs; WordDialog := WordDialogs.Item(84); //wdDialogFileSaveAs WordDialog.Show;
RegardsDo you make it right, it works too!0 -
Amost i have a solution. The last solution using the word dialog works properly, but i want to set a standard path. The documents must be ordered in a certain structuur and with the code before this part of code i had allready find where the document must be stored, and i have allready find which standard name he must get.
So, the user only have to choice, he want store this document or throw it away, and he can addapt the name if he wants. But in common way, he need only push the button to save.
The worddialog is not capebilty to set a standard path0 -
Still I don't know how to solve. Why does navision accept on an other place a bstr and here not?
WHY WHY WHY WHY..... BSTR0 -
You know bule, I really can't make sense of it either. I have tried running some of my own tests on this using several different ways of attempting to get the result bstr path.
At first I thought it might have been because of SelectedItems being a Collection datatype. Which is, of course, not supported by Navision.
This still may be the case but I really have no way of testing this (I don't think).0 -
Thanks Xypher,
It makes me mad. :evil:
In codeunit 412 is also a Bstr used, there is no error at all. Here, while using the filedialog navision complains.
](*,)0 -
Everything you use that has text is technically a Bstr, whether it is being referenced with an automation or not.
I think it is just a little buggy with this automation, go figure... it's Microsoft.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