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

Commented Unassigned: Is there a way to make Word open in readonly and not be able to edit the document [21132]

$
0
0
I can open a Word document as readonly so the [Read-only] shows but I want to disable the editing too. Is there additional options to stop people from being able to edit the document?
Comments: ** Comment from web user: ekirk0 **

Apply protection mode.

```
NetOffice.WordApi.Application app = new NetOffice.WordApi.Application();
app.DisplayAlerts = NetOffice.WordApi.Enums.WdAlertLevel.wdAlertsNone;
app.Visible = true;

NetOffice.WordApi.Document doc = app.Documents.Open(filename, false, true);

doc.Protect(NetOffice.WordApi.Enums.WdProtectionType.wdAllowOnlyReading, false, "password");
```


```
NetOffice.WordApi.Application app = new NetOffice.WordApi.Application();
app.Visible = true;
NetOffice.WordApi.ProtectedViewWindow window = app.ProtectedViewWindows.Open(filename);

```


New Post: Application.GetActiveInstances() returns wrong excel instances

$
0
0
its true.

this is because a mistake by microsoft. the COM running object table(ROT) returns always the first instance pointer in memory for any entry, sad but true. i suggest you to study latest source (\Tests\Concept Tests\ObjectFromWindow) to pin point all running applications once and for all !!! the test was made for ms-excel, let me know if you need help to use this concept in a different application. (of course, the NO 1.8 release is aware for the problem and want handle this better, by the way i'm sick of it to handle microsoft code issues....)

*Sebastian

Commented Unassigned: How to return a COMObject In a Collection? [21075]

$
0
0
internal static bool TryGetCustumXMLPart(this Document doc, string namespaceURI, out CustomXMLPart checkedPart) {
checkedPart = null;
using (CustomXMLParts parts = doc.CustomXMLParts) {
foreach (CustomXMLPart part in doc.CustomXMLParts) {
string partNamespaceURI = part.NamespaceURI;
if (partNamespaceURI == namespaceURI) {
checkedPart = new CustomXMLPart(part); << ERROR
return true;
}
}
}
return false;
}
Comments: ** Comment from web user: SebastianDotNet **

please send me a sample solution(btw: i use VS2010, NET 4) to public.sebastian[at]web.de
i need to reproduce the problem.

still not sure, whats the exception? whats the problem?, i see something goes wrong, but no chance for me to pin point the problem here. some code, no error/exception message..hey man! i'm not a sorcerer ;) gimme more input and will i help you as best i can you know.

Anyway: your code looks cool, just 1% percent of all my customers use the com proxy management directly.
*just nice to know* why you do this?

*Sebastian
(again: send me a sample solution if possible)

New Post: Application.Dispose

$
0
0
hey ho,

its your choice. keep the instance alive or dispose them. (the instance is still alive anyway what you do) if you dispose the instance then you have no chance any longer for any programatic access but keep in your mind, word doesnt dies if you release(dispose) the word instance. you have to call close (or quit, not sure) to shutdown the process.

i'm not sure you want, it sounds like for me keep the instance open and leave the user alone, or you still want track what happen?

hmm.. not sure but hope this helps
*Sebastian

Commented Unassigned: How to return a COMObject In a Collection? [21075]

$
0
0
internal static bool TryGetCustumXMLPart(this Document doc, string namespaceURI, out CustomXMLPart checkedPart) {
checkedPart = null;
using (CustomXMLParts parts = doc.CustomXMLParts) {
foreach (CustomXMLPart part in doc.CustomXMLParts) {
string partNamespaceURI = part.NamespaceURI;
if (partNamespaceURI == namespaceURI) {
checkedPart = new CustomXMLPart(part); << ERROR
return true;
}
}
}
return false;
}
Comments: ** Comment from web user: cgh_chen **

internal static bool TryGetCustumXMLPart(this Document doc, string namespaceURI, out CustomXMLPart checkedPart) {
checkedPart = null;
using (CustomXMLParts parts = doc.CustomXMLParts) {
foreach (CustomXMLPart part in doc.CustomXMLParts) {
string partNamespaceURI = part.NamespaceURI;
if (partNamespaceURI == namespaceURI) {
checkedPart = part.Detach(); //CALL extension method, This COMObject should be dispose explicit, after not using.
return true;
}
}
}
return false;
}

New Post: Application.Dispose

$
0
0
I have notice the code may call Close() to shutdown the process.
public virtual void Dispose(bool disposeEventBinding){
...
// call quit automaticly if wanted
        if (_callQuitInDispose)
            CallQuit(_underlyingObject);

        // release proxy
        ReleaseCOMProxy();

        // clear supportList reference
        _listSupportedEntities = null;

        _isDisposed = true;
        _isCurrentlyDisposing = false;
    }
/// <summary>
    /// calls Quit for a proxy
    /// </summary>
    /// <param name="proxy"></param>
    private static void COMObject.CallQuit(object proxy)
    {
        try
        {
            if (Settings.EnableAutomaticQuit)
                Invoker.Method(proxy, "Quit");
        }
        catch (Exception exception)
        {
            DebugConsole.WriteException(exception);
        }
    }
Settings.cs
/// <summary>
    /// Get or set the Quit method for an application object was automaticly called while Dispose. false by default
    /// </summary>
    public static bool EnableAutomaticQuit
    {
        get
        {
            return _enableAutomaticQuit;
        }
        set
        {
            _enableAutomaticQuit = value;
        }
    }

Created Unassigned: How to Stop Tab Key add new row, Word 2013 [21158]

$
0
0
Office 2007 / 2010, I can use key hook, stop the add new row action.
Word 2013, key hook do nothing.

Commented Unassigned: How to Stop Tab Key add new row, Word 2013 [21158]

$
0
0
Office 2007 / 2010, I can use key hook, stop the add new row action.
Word 2013, key hook do nothing.
Comments: ** Comment from web user: cgh_chen **

Sub NextCell()
'
' NextCell Macro
' Moves to the next table cell
'
' Selection.MoveRight Unit:=wdCell
End Sub

combine with KeyBindings override shotcut key


Commented Unassigned: How to Stop Tab Key add new row, Word 2013 [21158]

$
0
0
Office 2007 / 2010, I can use key hook, stop the add new row action.
Word 2013, key hook do nothing.
Comments: ** Comment from web user: cgh_chen **

BUT I lost the default action when selection is out of tab. :(

Commented Unassigned: How to return a COMObject In a Collection? [21075]

$
0
0
internal static bool TryGetCustumXMLPart(this Document doc, string namespaceURI, out CustomXMLPart checkedPart) {
checkedPart = null;
using (CustomXMLParts parts = doc.CustomXMLParts) {
foreach (CustomXMLPart part in doc.CustomXMLParts) {
string partNamespaceURI = part.NamespaceURI;
if (partNamespaceURI == namespaceURI) {
checkedPart = new CustomXMLPart(part); << ERROR
return true;
}
}
}
return false;
}
Comments: ** Comment from web user: ekirk0 **

Instead of iterating all the custom xml use this api method and expect to only get one instance. I don't think your supposed to have more than one of the same namespace stored.

CustomXMLParts.SelectByNamespace(classNameSpace)

Have a utility class for Storing and Loading a xml serialized class.
See attached solution.

```
NetOffice.WordApi.Application app = new NetOffice.WordApi.Application();
app.DisplayAlerts = NetOffice.WordApi.Enums.WdAlertLevel.wdAlertsNone;
app.Visible = true;

// add a new document
NetOffice.WordApi.Document doc = app.Documents.Add();

//create a new storage class instance
var info = new InfoStore() { ID = 112233, Name = "hello" };

//store info into the document custom xml parts
CustomXmlPartUtil.Store<InfoStore>(doc.CustomXMLParts, info);

//load the serialized xml infoStore.
var infoSaved = CustomXmlPartUtil.Load<InfoStore>(doc.CustomXMLParts);

app.Quit();
app.Dispose();
```

New Post: how to Copy pivotChart to Word

$
0
0
Hi,

I try but i don't found how do that... Is it possible to copy the xXX Excel to Word with the library ?

Thx,

New Post: Correct/best way to inherit from NetOffice.AccessApi.Form to use typed forms

$
0
0
I want to use typed Forms inside an Access Addin. This allows access to controls with Intellisense and compile-time checks:
NetOffice.AccessApi.Form frm1 = Main.App.Forms("Customers");

CustomersForm frm2 = new CustomersForm(frm1.UnderlyingObject);
string dummy2 = frm2.CustomerID.Value.ToString;

CustomersForm frm3 = new CustomersForm(frm1);
string dummy3 = frm3.CustomerID.Value.ToString;
I get it work passing "Application.Forms" collection in constructor:
using NetOffice.AccessApi;

public class CustomersForm : NetOffice.AccessApi.Form
{

    public CustomersForm(NetOffice.AccessApi.Form frm)
    {
        base.New(Main.App.Forms, frm.UnderlyingObject);
    }

    public CustomersForm(object comProxy)
    {
        base.New(Main.App.Forms, comProxy);
    }

    public TextBox CustomerID {
        get { return (NetOffice.AccessApi.TextBox)this.Controls("DNI"); }
    }

    public TextBox CustomerName {
        get { return (NetOffice.AccessApi.TextBox)this.Controls("CustomerName"); }
    }

    public ComboBox CustomerCity {
        get { return (NetOffice.AccessApi.ComboBox)this.Controls("CustomerCity"); }
    }
    
}
, where "Main.App" is "Addin.Application" property.

I don't like to explicitly pass "Application.Forms" collection in constructor. But i didn't find how to use "ParentObject" argument of standard NetOffice.AccessApi.Form constructor.

As said, it's working. But i'm wondering if there are a better way to do this.

Any ideas?

Thanks.

Commented Unassigned: Excel Pivot Table SourceData Range >65536 Crashes [21086]

$
0
0
Hi Guys.

Running 1.6 and am trying to create a Pivot Table in Excel. I can get it to generate fine as long as the SourceData range does not go over 65536. If I go to 65537 I get:

```
{"Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))"}
```

If I create the table in Excel manually it works fine. I assume there is a ushort variable limit to blame here? Here is the code that causes the problem (abbreviated to save space):

```
var workbook = ExcelApplication.ActiveWorkbook;
if (workbook == null)
return;

var DataWorksheet = (Worksheet)workbook.Worksheets.FirstOrDefault(ws => ((Worksheet)ws).Name == "Data");
if (DataWorksheet == null)
return;

var pivotsheet = workbook.Worksheets.Add() as Worksheet;
if (pivotsheet == null)
return;

// THE EVENTUAL PROBLEM WHEN > 65536
var usedrange = DataWorksheet.Range("A1:U65537");

//THIS LINE WILL CAUSE THE EXCEPTION WHEN usedrange IS > 65536
var pivotcache = workbook.PivotCaches().Add(XlPivotTableSourceType.xlDatabase, usedrange);

var pivottables = pivotsheet.PivotTables() as PivotTables;

if (pivottables != null)
{
var pivottable = pivottables.Add(pivotcache, pivotsheet.Range("A1"), "PivotTable1");
pivottable.InGridDropZones = false;
}
```

Thanks
Ernie
Comments: ** Comment from web user: aesalazar **

Anything? At least a workaround?

New Post: Read data from Excel Spreadsheet

$
0
0
Is it possible to use the ExcelApi to read data from an Excel spreadsheet, I'm trying to replace the use of OleDb due to limitations with remote host Excel drivers, below is an example of code that works locally but not remotely, hence the need to modify:

OleDbConnection conn;

conn = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=" + filename + ";Extended Properties=\"Excel 8.0;HDR=NO;IMEX=1;\"");

var tblSchema = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] { null, null, null, "TABLE" });

string sheetName = tblSchema.Rows[0]["TABLE_NAME"].ToString();
string getFileName = Path.GetFileName(filename);
string tableName = getFileName.Substring(0, getFileName.Length - 4);

var cmdEdl = new OleDbCommand("SELECT * FROM [" + sheetName + selectRange + "]", conn);

OleDbDataReader drEdl = cmdEdl.ExecuteReader();

Any help would be much appreciated :-)

New Post: NetOffice for Dynamics


New Post: NetOffice for Dynamics

$
0
0
hey man,

i do not have a legal license for MS Dynamics today. I need this in order to analyze the programing interface and generate NO Code(NO Code is generated), create qa tests and so on. (and last but not least, i need a support expert, YOU???)

i want help you as best i can :) BUT you have to help me also.

let me know ;)

New Post: Custom Task Pane for each Powerpoint document

$
0
0
Hi,

is there an easy way to manage a custom task pane for multiple powerpoint documents? As I understand it correct I need a new instance for each document. When defining a task pane as described in the excamples I see the task pane only in the first document.
As a first test I saved the CTPFactoryInst (don't dispose it) and call the ctpFactory.CreateCTP Method again.

It's not nice but it works. The problem appears if the user hides the task pane and want's to see it again. In this case I have find the right task pane to the right powerpoint document.

Is there an solution in NetOffice to handle such or problem or does someone know any "Best Practise" to handle this?


Thomas

New Comment on "DeveloperToolbox_English"

$
0
0
Hello, how can I Word header and footer? Can write an example? Thanks a million

New Comment on "Word_Examples_EN"

$
0
0
Hello, I want to operate the word headers and footers, and ask how can I do ah? You can write an example? Thank you very much!

New Post: word.document.PrintOut issue

$
0
0
To All,

I tried using the word.document.printout function, can't seem to get it to work.
The parameter is:
print one page, fit it to one page (so i can ignore margins etc). But the signiture of the printout so I've this:

object background = false;
            object append = false;
            object range = WORD.Enums.WdPrintOutRange.wdPrintFromTo;
            object outputfilename = string.Empty;
            object _from = 1;
            object _to = 1;
            object item = WdPrintOutItem.wdPrintDocumentContent;
            object copies = 1;
            object pages = string.Empty;
            object pageType = WdPrintOutPages.wdPrintAllPages;
            object printtofile = "";

            object collate = false;
            object filename = string.Empty;

            object activePrinterMacGX = string.Empty;
            object manualDuplexPrint = false;

            object printZoomColumn = 1;
            object printZoomRow = 1;

            object printZoomPaperWidth = "";
            object printZoomPaperHeight = "";


            doc.PrintOut(   background,
                    append, 
                    range, 
                    outputfilename, 
                    _from, 
                    _to, 
                    item, 
                    copies, 
                    pages, 
                    pageType, 
                    printtofile, 
                    collate, 
                    filename, 
                    /* activePrinterMacGX, */ /* commented out because not supported? */
                    manualDuplexPrint,
                    printZoomColumn, 
                    printZoomRow, 
                    printZoomPaperWidth, 
                    printZoomPaperHeight);
But this fails everytime, ... if i use
doc.PrintOut();
this would work.

Any Ideas or pointers?

Psc0425
Viewing all 1741 articles
Browse latest View live


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