Quantcast
Channel: NetOffice - MS Office in .NET
Viewing all 1741 articles
Browse latest View live

Commented Unassigned: NetOffice font misinterpretation? [20989]

$
0
0
I have a small application that opens a MS Word template, inserts some data into some bookmarks and saves the result as PDF.

However, some of the fonts in the template are barcodes and when I open the resulting PDF, the values just come out as regular characters instead of barcodes.

Previously (before migrating to NetOffice) this worked and the result showed barcodes where it was supposed to, but not anymore.

Any idea as to what the problem is here or is this not supported by NotOffice?

(the font is located where all other fonts are located).
Comments: ** Comment from web user: SebastianDotNet **

not sure...

what i see is some of the following problems

1) the font is not installed on the current system (i see: its not the problem)
2) the pdf printer has problems to understand what happen (but it works formerly, please explain more about your previous solution, this means its VBA, Interop, VSTO, whatever?)
3) you may use an incompatible ThreadCulture or Codepage (my favourite)

As far i'm understand, you have an pdf printer installed on your system and use just the Print or PrintOut method for your result, aren't so? Its much helpful for me to see a codesnippet to clearify the problem.

*Sebastian


Closed Unassigned: Excel: TargetInvocationException with larger amount of Range accesses [20987]

$
0
0
Hi there, we're using Excel 2013 templates and the latest NetOffice 1.7.0 libs in a C# assembly to create reports from data stored in an MS-SQL server database. This works well, unless a certain amount of data is exceeded. My code looks like this:

// exportSheet is a Worksheet instance
ListObject dataTable = exportSheet.ListObjects["DataTable"];
Range dataTableBody = dataTable.DataBodyRange;
...
// Loop start...
// recordCount increases with evaluated records from DB
dataTableBody[recordCount, 1].Value = recordCount; //Exception may occur here...
dataTableBody[recordCount, 2].Value = meterRecord.Timestamp; //...or here or...
dataTableBody[recordCount, 3].Value = meterRecord.IntervalValueDiff; //...or here
...
// Loop end

When a (non deterministic) amount of data is exceeded, I get a COMException with an inner exception of type System.Reflection.TargetInvocationException in the lines where I try to assign the cell values (see attached file). This happens with more than roughly 500-700 records on my machine - with fewer records, everything is fine.

Any chance to find out, what the source of the problem is? Any hint for a workaround?

Best regards,
Hans
Comments: Hans find the problem in his own code.

we are happy to help Hans next time :)

*the NO crew members

New Post: DocVariables access slow

$
0
0
Hi,

great tool, but if i call
word.ActiveDocument.Variables.Clear() 
or update a Variable via
var varToWrite = variables.FirstOrDefault(variable => variable.Name == name);
varToWrite.Value = value;
the access is very slow (office 2013).

What can I do?

Regards,
Christoph

New Post: Word Add-in pane not appearing

$
0
0
I’m new to NetOffice. Very cool product! I appreciate the hard work.

My MS Word add-in pane was appearing until I clicked the Close X button on the add-in. Now it won't appear. However, when I launch MS Word via NetOffice.DeveloperToolbox's OfficeUI feature, my add-in pane is visible.

I have a MS Word menu button and that button toggles the Visible state of the pane. That button works when Word is launched via NetOffice.DeveloperToolbox. But it doesn't show the pane when Word is launched normally.

When I launch MS Word, a document opens automatically. It's that same document that was open when my pane was visible and I clicked the Close/X button. I've added break points to my add-in's AddIn class and it is indeed being created when MS Word starts.

Maybe MS Word saves the add-in's Visible in the document. Or perhaps in a registry key. Or even in a file. But even so, why doesn't setting Visible=true show the pane?
  • Windows 7 x64
  • Office 2010 Home & Student x64
  • NetOffice 1.6.0
  • When I created the add-in via the wizard, I choose Current User.
namespace FcptWordEmrTaskPaneAddIn {
    [COMAddin("FcptWord", "First Choice PT MS Word EMR Add-In", 3)]
    [GuidAttribute("2A47524B-E1A2-4F32-9826-864EE9DFA740"), ProgId("FcptWord.TaskPaneAddin")]
    public class Addin : COMAddin {
        public Addin() {
            this.OnStartupComplete += new OnStartupCompleteEventHandler(Addin_OnStartupComplete);
            this.OnConnection += new OnConnectionEventHandler(Addin_OnConnection);
            this.OnDisconnection += new OnDisconnectionEventHandler(Addin_OnDisconnection);

            var app = Word.Application.GetActiveInstance();
            
            string title = "EMR Task Pane";
            TaskPanes.Add(typeof(AddInUI), title);
            foreach (var tp in TaskPanes) {
                if (tp.Title == title) {
                    tp.DockPosition = MsoCTPDockPosition.msoCTPDockPositionLeft;
                    tp.DockPositionRestrict = MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoHorizontal;
                    tp.Width = 150;
                    tp.Visible = true;
                    tp.Arguments = new object[] { this };
                    var cc = app.CustomizationContext;
                }
            }
        }

        void Addin_OnConnection(object Application, NetOffice.Tools.ext_ConnectMode ConnectMode, object AddInInst, ref Array custom) { }

        void Addin_OnStartupComplete(ref Array custom) {
            CreateUserInterface();
        }

        void Addin_OnDisconnection(NetOffice.Tools.ext_DisconnectMode RemoveMode, ref Array custom) {
            RemoveUserInterface();
        }

        void CreateUserInterface() {
            var app = Word.Application.GetActiveInstance();
            CommandBar fileMnuBar = app.CommandBars["File"];
            fileMnuBar.Reset();
            var OptionsButton = (CommandBarButton)fileMnuBar.Controls.Add(MsoControlType.msoControlButton, System.Type.Missing, System.Type.Missing, fileMnuBar.Position + 3, true);
            OptionsButton.Tag = "cxrnd1024";
            OptionsButton.Style = MsoButtonStyle.msoButtonIconAndCaption;
            OptionsButton.Caption = "EMR";
            OptionsButton.ClickEvent += new CommandBarButton_ClickEventHandler(FcptEmr_ClickEvent);
        }

        void FcptEmr_ClickEvent(CommandBarButton Ctrl, ref bool CancelDefault) {
            foreach (var tp in TaskPanes) {
                try {
                    tp.Visible = !tp.Visible;
                } catch (Exception) { }
            }
        }

        void RemoveUserInterface() { }
    }
}

New Post: Few errors in VS Express and SharpDevelop

$
0
0
When trying to run the project in SharpDevelop 5 I'm getting:
Project is configured as dll and no execution command is specified.
You can specify an execution command in the project options.
You should config you self. It is not NetOffice question.

New Post: Few errors in VS Express and SharpDevelop

$
0
0
hey man

it looks like for an addin project.

go the project options(menu: Project/Project Options and you a face a tabcontrol component
select the 'Debug' tab now.
select the start option 'start external program' and choose your office application (EXCEL.EXE or whatever)
close the option page and hit F5 to debug.

*hope this helps
Sebastian

New Post: Word Add-in pane not appearing

$
0
0
okay... this means the pane is visible at first MS-Word start and never again? (it looks like for an unhandled exception)
if its possible, please send me your solution to public[at]sebastian.web.de(remove private code, i dont need this to clearify the situation)

BTW: i suggest you to avoid 'GetActiveInstance()' this method gives you the first instance in memory but not sure its your's. (may multiple word instances currently working)

Better idea:

Keep the application in a private field:

private NetOffice.WordApi.Application _app;

void Addin_OnConnection(object Application, NetOffice.Tools.ext_ConnectMode ConnectMode, object AddInInst, ref Array custom)
{
_app = new NetOffice.WordApi.Application(null, Application);
}

void Addin_OnDisconnection(NetOffice.Tools.ext_DisconnectMode RemoveMode, ref Array custom)
{
RemoveUserInterface();
 _app.Dispose();
}

(Nice to know: NO 1.7 makes this easier with the NO Tools, the application is available here as addin instance property)

*Sebastian

New Post: DocVariables access slow

$
0
0
what means very slow in fact? (milliseconds, seconds or minutes?)

i want reproduce your scenario but need to know the count (and may content) of your variables and your office document format(.xlsx?) and its a new document or existing document.

(my current idea is is: the application use some harddrive operations to validate the variables and this ops decrease the performance)

*Sebastian

New Post: DocVariables access slow

$
0
0
Here some facts:
  • the performance ist reduced by factor 30 (about)
  • The count of variables is about 70, strings with length of 10-50
  • The document ist new generated Word-Document via a template (loading DOCX)
  • this problem occours at an customer sytem, at my test system, all ist fine
  • My previous method controls addin/opdating variables by OLE-Automation (Visual Foxpro). In this case, there ist a small performance impact only at the customer system (about factor 2),
  • The customer uses Office 2010 (not 2013), my Test System uses Office 2003.
  • The Customer uses Office in as Terminal Services Environment (Windows 2003)
  • I try to take some measures in end of the next week.
What do you mean with "harddrive operations to validate"? Word hosts the Variables in memory.

If this is too specifically for this forum, you can mail me: Dressler.at.comfuture.de

-Christoph

Commented Unassigned: NetOffice font misinterpretation? [20989]

$
0
0
I have a small application that opens a MS Word template, inserts some data into some bookmarks and saves the result as PDF.

However, some of the fonts in the template are barcodes and when I open the resulting PDF, the values just come out as regular characters instead of barcodes.

Previously (before migrating to NetOffice) this worked and the result showed barcodes where it was supposed to, but not anymore.

Any idea as to what the problem is here or is this not supported by NotOffice?

(the font is located where all other fonts are located).
Comments: ** Comment from web user: aidal **

Hi Sebastian,

I'm sorry to say that I had to migrate back to the previous solution which was Office 2010 interop.
I wanted to try out NetOffice to get rid of the Office version dependency but in order to get this to work, I had to go back.

Actually I wasn't printing the document because it kept stalling my process (saying that the application was busy), so I first tried to save it as PDF and then let some other application take care of the printing.
But the PDF was saved as I describe with characters instead of barcodes. I also tried to save to DocX but the result was the same.

I tried using ___SaveAs___, ___SaveAs2___ and ___ExportAsFixedFormat___ but the result remained the same - no barcodes.

So I had to go back to where I came from, using a virtualbox image with this older Office (2010) to re-build the service.

I found out one thing though, and that is not to deploy local copies of the Office assemblies with the application - this was causing the Winword process to hang - as soon as I deleted these from the deploy folder, that issue disappeared.

I wonder how this would be done with NetOffice - should the NetOffice assemblies not be distributed with the application but instead be installed on the system (GAC)?
I'm wondering this because I was seeing the same hanging process issue when I tried printing directly from the Word.Application with NetOffice - that is why I started the whole PDF thing in the first place.

/Aidal

New Post: DocVariables access slow

$
0
0
hey man,

i didnt understand your prev solution. ( i need this to compare & analyze the problem) sounds like VBA for me. (BTW: FoxPro is still alive? never heard of them since 2000....)

what i mean with hd operations is: word is a bit special in deal with meta data. this means, word check for the doc/docx file in any case here for all meta data operations( you can see/observe this with a a special SysInternals tool(by the great Mark Russinovic).
thats the reason why i ask for its new or existing file.(i see, its new and UNSAVED(true???), no need for hd operations)

What can i say currently is:

may bad news: accessing a COM application from .NET is MUCH slower as VBA or VB6/5. ( a lot of .NET infrastructure code is necessary to break the wall from managed to unmanaged) regardless from any API(VSTO, NetOffice, Interop) you want you use.
you may face this kind of performance problem. the only way to fix this is, reduce the count of calls to office as much you can. in other words: the call to office himself is the reason for the performance decrease.

Summary: This is a performance problem(very special, normaly is gimme some code snippets and i told you whats happen).
This situation is different. Anyway, i want reproduce the scenario now, (A)VBA in Word, (B)NetOffice in .exe. if its done, i want come back.

*Sebastian

New Post: Word Add-in pane not appearing

$
0
0
I got it working. Thank you for the suggestions. Your assistance is appreciated. Thanks for GetActiveInstance() tip too!

Greg

New Post: Accessing table field properties such as "TextAlign" in Microsoft Access 2013

$
0
0
Much thanks to the creator and everyone who has made this project possible. It has definitely made things a lot more organized and easier when dealing with the Microsoft.Office.Interop libraries.

I have a question concerning the use of a field property. The following code would normally just work under the Microsoft.Office.Interop.Access and Microsoft.Office.Interop.Dao namespaces.
// open database

NetOffice.AccessApi.Application app = new Application()
Database db = app.DBEngine.Workspaces[0].OpenDatabase(filePath);
TableDef myTable = db.TableDefs[tableName];
Field myField = myTable.Fields["FirstName"];
Properties myProperties = myField.Properties;   //I get 39 properties for myField
Property fieldTextAlign = myProperties["TextAlign"];
var value = fieldTextAlign .Value;
Currently when I look at the Properties and Property Class in NetOffice, I get an error:
  1. base = {"Class not exists: NetOffice.AccessApi.Property"}
Microsoft intellisense shows that Properties is in the NetOffice.DAOApi namespace even though my original application object (app) belongs in the AccessApi namespace. How do I access these properties. I tried casting but could not make it work. Any help greatly appreciated.

Dun

Created Unassigned: Toolbox 1.2 won't start - loadFromRemoteSources [21009]

$
0
0
Hi,

I tried to install NetOffice 1.6 and the corresponding Toolbox 1.2 because I use Visual Studio Express 2013.

The toolbox is located on C:\tools\... but when I try to start it, I get an error message (see attached screenshot):
```
1 | An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information. | NotSupportedException | Void .ctor()
```
I run on Windows 7 64bit with Office 2010 and .NET 4.5.

Any ideas?
Thanks.

New Post: Excel: Apply a TableStyle to a QueryTable

$
0
0
I am trying to get a data from a database into Excel and apply a table style to it in the most quickest time; whilst still using NetOffice for the interoperability it offers. I assume that using Excel's inbuilt query functions will be far faster so I am using that (please correct me if I am wrong on this)

I can use a query table:
var sheet = (_excel.ActiveSheet as Excel.Worksheet);
var rng = sheet.Range("A1");

var qt = sheet.QueryTables.Add("ODBC;...", rng, "SELECT * FROM myTable");
qt.Refresh();
and this will import the data correctly (e.g. dates actually display as dates etc...). But when I try and access the ListObject to apply a TableStyle I get an exception.

Now if I add a list object like:
var sheet = (_excel.ActiveSheet as Excel.Worksheet);

var qt = sheet.ListObjects.Add(
    Excel.Enums.XlListObjectSourceType.xlSrcQuery,
    "ODBC;...",
    null,
    Excel.Enums.XlYesNoGuess.xlNo,
    rng,
    "TableStyleMedium9").QueryTable;

qt.CommandType = Excel.Enums.XlCmdType.xlCmdSql;
qt.CommandText = "SELECT * FROM myTable";
qt.Refresh();
The the dates in the query display as decimal numbers and not dates...

I could just format the columns afterwards, but the problem is that I won't actually know the query that is being run as the user types this at runtime, so I would prefer to get Excel to do this.

So essentially, what I want, is to use the first bit of code and apply a TableStyle to it.

Can anyone help?

Commented Unassigned: Toolbox 1.2 won't start - loadFromRemoteSources [21009]

$
0
0
Hi,

I tried to install NetOffice 1.6 and the corresponding Toolbox 1.2 because I use Visual Studio Express 2013.

The toolbox is located on C:\tools\... but when I try to start it, I get an error message (see attached screenshot):
```
1 | An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information. | NotSupportedException | Void .ctor()
```
I run on Windows 7 64bit with Office 2010 and .NET 4.5.

Any ideas?
Thanks.
Comments: ** Comment from web user: SebastianDotNet **

hey man,

in fact: its not allowed to execute a .NET assembly from a network location.
(default .net policy)

change the .NET policy(management console) or shift the solution to local hard drive and try again.

helps?
*let me know

Sebastian

New Post: Accessing table field properties such as "TextAlign" in Microsoft Access 2013

$
0
0
in which codeline occurs the problem? (its not clearly for me)
please me let me know also your NetOffice version and your current office version.
(I need this to reproduce your scenario and give you some hotfix tips until i pin point the problem)

*sebastian

Commented Unassigned: Toolbox 1.2 won't start - loadFromRemoteSources [21009]

$
0
0
Hi,

I tried to install NetOffice 1.6 and the corresponding Toolbox 1.2 because I use Visual Studio Express 2013.

The toolbox is located on C:\tools\... but when I try to start it, I get an error message (see attached screenshot):
```
1 | An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information. | NotSupportedException | Void .ctor()
```
I run on Windows 7 64bit with Office 2010 and .NET 4.5.

Any ideas?
Thanks.
Comments: ** Comment from web user: flxmx **

By the way... I found a copy of the toolbox version 1.1 on a backup drive. This version installs perfectly.

Cheers
Felix

Commented Unassigned: Toolbox 1.2 won't start - loadFromRemoteSources [21009]

$
0
0
Hi,

I tried to install NetOffice 1.6 and the corresponding Toolbox 1.2 because I use Visual Studio Express 2013.

The toolbox is located on C:\tools\... but when I try to start it, I get an error message (see attached screenshot):
```
1 | An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information. | NotSupportedException | Void .ctor()
```
I run on Windows 7 64bit with Office 2010 and .NET 4.5.

Any ideas?
Thanks.
Comments: ** Comment from web user: flxmx **

>
in fact: its not allowed to execute a .NET assembly from a network location.
(default .net policy)
> change the .NET policy(management console) or shift the solution to local hard drive and try again.
It is not located on a network drive.
Btw version 1.1 does start perfectly from the same location.

New Post: Excel: Apply a TableStyle to a QueryTable

$
0
0
So I can see that when I create a list object that the NumberFormat of the whole range is set to "General"....however, on the QueryTable (which has the correct number formatting), it is null which means that the range has different formats according to the documentation.

So my question is, how do I get the ListObject to take the NumberFormat from query like QueryTable does.
Viewing all 1741 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>