Quantcast
Channel: Word for Developers forum
Viewing all 4350 articles
Browse latest View live

Filling word document from xml data source

$
0
0

In microsoft exel i can insert xsd schema, put data fields from schema to worksheet cells. after click "import" I select xml file and my xlst file filling with data.

Can I somehow do the same in the Office Word? ( I'm using word 2010.) (i know how po insert xsd schema, but i don't know how to import xml file). Can I do this only by programming?

Thank You in advance


VBA script for signature Outlook (Word model)

$
0
0
You cannot vote on your own post                                 

We are using a vbscript to assign a Outlook 2010 signature to the users that are logging in the network.

A few things are a problem. First the logo is different when we open it in a editor it looks sharp etc. In Outlook it looks less sharp and smaller or larger. I have read that this is because Outlook is making a 96 dpi image of it. So i saved the jpg as a 96 dpi image but then it becomes 500 kb so thats to large.

The second problem i have is the color of the text in the script. Whatever i use for color the color is not much changing in Outlook. It looks much lighter then the color code says. Below is a part of the script. Is there something not right?

For example i have made the color www.company.com magenta but it stays the same in Outlook after restarting the system twice. It is also not underlined anymore so it is not a link. Something in the code must be wrong....

Between the lines the fonts are made arial 10 pt and a kind of darkgrey, but in Outlook it isgrey, also when you print it..

Outlook seems to do things on his own or is ignoring the script RGB CODE in this case? For example when i make the RGB (255,0,0) the tekst should be red but it stays the same...

My conclusion at the end is that something goes wrong with the placed files beneath the %appdat%\microsoft\signature folder.  After some testing i put a right logo in the .htm file there and then he displays the right logo. After i run the script again new files are placed overwriting the excisting ones (.htm .rtf .txt) and then the wrong wuality logo is back every time.
In that signature folder there is also a folder writen after the script has run with the same name as comes back in the script. In that folder is after every run off the script a image001.jpg placed by everyone on the clients. Most of them get one image001.jpg. My and several others get 2 image001 and image002.jpg which is much smaller and thats the image of the logo which is wrong and loaded into Outlook signature..

Set objSysInfo = CreateObject("ADSystemInfo")

strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)

strVoornaam = objUser.FirstName
strAchternaam = objUser.LastName
strTitle = objUser.Title
strDepartment = objUser.Department
strCompany = objUser.Company
strPhone = objUser.telephoneNumber
strFax = objUser.FacsimileTelephoneNumber
strMobile = objUser.Mobile
strLand = objUser.st
strGroet = objUser.StreetAddress
strDescription = objUser.Description
strOffice = objUser.PhysicalDeliveryOfficeName
strMail = objUser.Mail
strWeb = objUser.wWWHomePage
strPObox = objUser.postOfficeBox
strCity = objUser.l
strZip = objUser.postalcode
strHome = objUser.HomePhone
strIP = objUser.ipPhone
strNotes = objUser.info


Set objWord = CreateObject("Word.Application")
objWord.Visible = False
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
objSelection.Style = "No Spacing"

Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature

Set objSignatureEntries = objSignatureObject.EmailSignatureEntries

objSelection.Font.Name = "Arial"
objSelection.Font.Size = "10"
objSelection.Font.Color = RGB(47,79,79)
objSelection.Font.Bold = True
objSelection.TypeText " with kind regards," & Chr(11)
'If strGroet = not "" then objSelection.TypeText strGroet
'objSelection.TypeText ","
ObjSelection.TypeText Chr(11)
objSelection.TypeText strForname & " "
objselection.TypeText strBack & Chr(11)
objSelection.TypeText strTitle & " "
objSelection.TypeText strNotes & Chr(11)
'objSelection.TypeText Chr(11)

'ObjSelection.TypeText Chr(11)
Set objShape = objSelection.InlineShapes.AddPicture("\\path\logo.jpg") & Chr(11)
ObjSelection.TypeText Chr(11)

objSelection.TypeText "Internet: "

objSelection.Font.Name = "Arial"
objSelection.Font.Size = "10"
objSelection.Font.Color = RGB(255,0,255)
objSelection.Font.Italic = False
objSelection.Font.Bold = False
If strWeb = "" Then
objSelection.TypeText "http://www.company.com" & Chr(11)
'objSelection.TypeText Chr(11)
else objSelection.TypeText strWeb & Chr(11)
End If

objSelection.Font.Name = "Arial"
objSelection.Font.Size = "9"
objSelection.Font.Color = RGB(47,79,79)
objSelection.Font.Italic = False
objSelection.Font.Bold = True


freddie

Printer "Offline"

$
0
0

Does anyone know why printers still have a status of "Offline" (that is inevitably extremely difficult to find the setting for to put them online) at all? Is there some reason I, or anyone might want to tell their printer to be offline? 

Is it just one of those things that made sense sometime back in the past and so they continue it, or is it actually something, that someone somewhere actually needs?  

Is there some way that a Microsoft Office for Developers person can get around this frustration by automatically turning a printer online?  (for those of us who have no idea in the world why anyone would ever want their printer "offline")


how to get customer list template ?

$
0
0

Hi guys,

so far i've written a "template.dotx" file which contains a multi-level list template in it.

and i wanna use this list template, so i write the code below :

string exePath = System.Windows.Forms.Application.StartupPath + "\\";
            Word._Application wordApp = new Word.Application();
            Word._Document templateDoc = wordApp.Documents.Open(exePath + "template.dotx");
            templateDoc.Activate();


            Word.ListTemplate lt = wordApp.ListGalleries[Word.WdListGalleryType.wdOutlineNumberGallery].ListTemplates[7];

but it seems the wordApp object doesnt find my list template, for  "wordApp.ListGalleries[Word.WdListGalleryType.wdOutlineNumberGallery].ListTemplates" only have 7 default template?

but if i open the dotx with office2013, it contains the list template i've created.

is there anyway i can obtain the template?

Editing an embedded object in Word 2013 does not work

$
0
0

Hi

We have developed a graph document that can be inserted as an embedded object and can be edited in place by our OLE server application. This works on all previous versions of Word. But this is longer the case in Word 2013 and the server application is opened instead of activating as in place editor and replacing the Word toolbar. We can insert the graph object into Excel and Powerpoint 2013 and edit the graph object in place but for some reason this does not work in Word 2013. I have tried creating a basic test application using the MFC visual studio wizard in VS 2005 and VS 2013 but both test applications have the same problem and work when testing in Word 2010.

Has this supported been removed for Word 2013 or is this a known issue that will be fixed?

Issue when Disabling Context Menu and shortcuts in Word Documents.

$
0
0

I need to protect a word document from cut, copy , paste , paste Special, save and save Shortcuts.

So far I have been able to achieve my goals by using the code below:

Imports Microsoft.Office.InteropDim WrdApp As Word.ApplicationDim WrdDocs As Word.DocumentsDim WrdDoc As Word.DocumentDim cb As CommandBarDim cbCtl As CommandBarControlForEach cb In WrdDoc.CommandBarsIf cb.Name <>"ClipBoard"Then
                cbCtl = cb.FindControl(,21,,,True)'(Cut Disabled)IfNot cbCtl IsNothingThen cbCtl.Enabled =False

                cbCtl = cb.FindControl(,19,,,True)'(Copy Disabled)IfNot cbCtl IsNothingThen cbCtl.Enabled =False

                cbCtl = cb.FindControl(,22,,,True)'(paste Disabled)IfNot cbCtl IsNothingThen cbCtl.Enabled =False

                cbCtl = cb.FindControl(,755,,,True)'(Paste Special Disabled)IfNot cbCtl IsNothingThen cbCtl.Enabled =FalseEndIfNext
   WrdApp.FindKey(WrdApp.BuildKeyCode(Word.WdKey.wdKeyControl, word.WdKey.wdKeyS)).Disable()
     WrdApp.FindKey(WrdApp.BuildKeyCode(Word.WdKey.wdKeyControl),Word.WdKey.wdKeyC).Disable()
 WrdApp.FindKey(WrdApp.BuildKeyCode(Word.WdKey.wdKeyControl), Word.WdKey.wdKeyX).Disable()

I have just found out that the latter code, works at the level of the entire word application and not at the level of each document; and that's my problem.

I need to disable the context menu and save options per documents ; user can save and copy from the first document, but could not for another document.

Is there a turn-around to this issue?

Your help is appreciated.

Best Regards.

c#, word addin, programmary disable autosave/autorecover.

$
0
0

Hello,

I making word addin in c# (visual studio 2013).

How i can programmary disable autosave and autorecovery in word addin?

Please give me example for an application-level add-in.

Regards,

Daro

Document Title for Automation

$
0
0

Hello,

we use the following code to find window handle

    FWordApp                := CreateOleObject('Word.Application');
    FConnected              := True;
    FWordApp.Visible        := False;
    FADoc  := FWordApp.Documents.Add(EmptyParam, False);
    sName := FADoc.Name + ' - ' + FWordApp.Name;
    FHandle := FindWindow(MSWordWndClass, PChar(sName));

This works for Word 2003 where sName is "Document1 - Microsoft Word" and coinsides with the document window title.

However, this does not work for Word 2013 where the title is "Document1 - Word" and sName is the same as above. Is there some other property that allows to find the correct title of the document window?

Thanks,

Vladimir 


Vladimir Belitski


Save word document in specific folder with specific filename from document

$
0
0

Hi all,

I have very basic knowledge and need a lot of help.

Basically I have created a quotation letter and have managed to create a macro with the help of the internet so the quotation number increases each time a new quote template is opened. I now need another macro (I believe) to save this document in a specific folder with the filename Quotation Number (and whichever number quote we are on).

As I have very basic understanding I need this set you very plainly please.

Thanks

graphics changes position when upgrading from word 2007 to 2013

$
0
0

Hello,

We have a large number of letters created in word 2007, with a first page header containing a logo. It is positioned on the page by giving xx cm absolute position relative/vertical to the page.

When opening these documents in word 2013 the logo is still correctly positioned.

However: When saving, (and Word asks to upgrade to latest format) - the logo moves a god 10 cm to the right and a bit down...

Checking the positioning it still says correctly xx cm absolute to page, but the position is terribly wrong...

Checking the anchoring it seems that the saving process have moved the anchoring from the first paragraph in the header and to a table which is in the header –and that Word considers absolute positon relative to page as to be relative to the table instead. Neither is convinient...

Any tips greatly appreciated

regards,
Jon Gunnar Pettersen

Populate a text based based on value selected in combo box

$
0
0

I would like to populate the contents of a text box based based on the selection of value in a combo box. 

I do not have an external data source to link to, the values in my combo box were entered via the "Drop-Down Form Field Options Window."  I would like to do something like this in VBA:


     If ActiveDocument.FormFields("cboBusDesc").DropDown.Value = "Accomodation and Food Services" Then
         ActiveDocument.FormFields("txtBusCode").Value = "7200"         Exit Sub
      End If
     
     If ActiveDocument.FormFields("cboBusDesc").DropDown.Value = "Agriculture" Then
         ActiveDocument.FormFields("txtBusCode").Value = "1100"        

         
But that doesn't work.  Can somebody help me out?
          

ConvertToShape return null

$
0
0

hello

    I want to insert a picture into word document and  Converts it to a free-floating shape , The method of ConvertToShape return NULL pointer of shapeptr. But the picture has been converted into free-floating shape. Because the pointer is null , so I can't do anything with the free-floating shape! the folowing is my source code , is any problem with my source code? thanks !!

 Word::SelectionPtr spSelection = m_pApp->Selection;
 Word::InlineShapesPtr spInlineShapes = spSelection->InlineShapes;
 Word::InlineShapePtr spInlineShape;
 COleVariant vtTrue((short)VARIANT_TRUE);
 COleVariant vtFalse((short)VARIANT_FALSE);
 spInlineShape = spInlineShapes->AddPicture(_bstr_t(lpPicFile), vtFalse, vtTrue);
 if (NULL != spInlineShape) {
  ShapePtr shape = spInlineShape->ConvertToShape();
  if (shape != NULL) {
      shape->ZOrder(msoSendBehindText);
  }
 }

Customizing image in a costumer button in word ribbon

$
0
0

Hi all. I am building a word application level addin. The problem is that I want that the buttons I create in the ribbon to show specific images. I made these bitmaps part of the resources, the addin runs ok but for some reason the bitmaps do not show in the buttons.

Here is my XML file:

 

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
  <ribbon>
    <tabs>
      <tab idMso="TabAddIns" label="myTab">
        <group id="myGroup" label="myGroup">
          <button id="btn1" label="Button" screentip="Button 1" size="large"
                  image="the path to the icon" 
                  onAction="OnBtn1" supertip="a tip" showImage="true"/>
       </group>
      </tab>
    </tabs>
  </ribbon>
</customUI>

The icon is a 16x16 bitmap with 16 colors. I can assure that the icon's path is a valid one. But for some reason when I run the addin the icon doesn't show.

Can anyone help me? Thanks.

Jorge


Jorge Teixeira

How to check if word/excel file is valid

$
0
0

Hi All,

     I need to check if the file is a valid doc/docx/xls/xlsx/pdf/jpg/jpeg/png file.

This will help me detect if the file is a valid file or if its extension has been renamed . 

Is there any way to do validate if the file is valid?

Any help/guidance would be greatly appreciated.

regards,

Pradeep

How can I extract the text in between two different styles in a word document and save the text to a new word document while preserving the formatting and styles of the text?

$
0
0

For example, I want all the text in between "Heading 1" and "Heading 2" to be extracted. I already have the code below to look for a particular style i just don't know how to extract the sections in between styles. 

                                   

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml;
using System.Xml.Linq;
using DocumentFormat.OpenXml.Packaging;
using Microsoft.Office.Interop.Word;

namespace GetStyles1
{

    class Program
    {


       static void Main(string[] args)
        {


            Application application = new Application();
            Document document = application.Documents.Open(@"C:\Users\t40627uhn\Desktop\Wiki\1\R2LAD.docx");

         foreach (Microsoft.Office.Interop.Word.Paragraph paragraph in document.Paragraphs)
{
    Style style = paragraph.get_Style() as Style;
    string styleName = style.NameLocal;
    string text = paragraph.Range.Text;

    if (styleName == "Heading 1") // do something
    {

    }

}

}

}

}


Mail-Merge to E-mail with Subject personalised by Mail-Merge Fields.

$
0
0

Mail-Merge to E-mail with Subject personalised by Mail-merge Fields

I know this is impossible, but it can be approximated. The attached code enables you to put character strings like “<<Addressee>>”, rather than real Mail-Merge Fields, in the Subject of a WORD Mail-Merge to E-mail. The routines in the code then change the Subject for each E-mail sent, so that the contents of the column ‘Addressee’ in the Mail-Merge Data Source are substituted for the “<<Addressee>>”. 

There is however a severe limitation on its usefulness. The Document has to be saved and re-opened after the code has been added to the Document for it to work. This is because the Document_Open routine has to initialise them_WORDapplication Object that controls the Merge. 

Background

For many years we have had an application that creates Excel Mail-Merge Data Sources from data held in an SQL Server Database. The application then draws on a library of WORD Templates changing MacroButtons in the Template into values from the Database. If the E-mail is going to multiple recipients the appropriate Mail-Merge Data Source is attached. Otherwise the Mail-Merge Fields are substituted by the application – thus avoiding the need for a mail-merge. 

The Document is then opened in WORD.  The user is then left to make any further changes and either send the E-mail or complete the Mail-Merge as normal. Any changes the User makes are captured when the Document closes. The first 255 characters of the Document Body are stored and cross-indexed in the SQL Server Database. The original document is stored in a Windows Folder structure, from where it can be retrieved when needed. 

What we now wish to do

So far our application populates the E-mail Envelope with the Subject. However when the User does a Merge to E-mail, the Subject is not transferred to the ‘Merge to E-mail’ Dialog. We would like to find a way of doing so.  This is not essential as the User can always copy and paste, but it’s a little inelegant. 

When the User clicks OK in this Dialog we then want the WORD Mail-Merge to personalise the Subject line of each E-mail with Fields from the Mail-Merge Data Source – without the need to close and re-open the document. 

Progress to Date

So far we have developed the code that actually does the Merge. However it has to be in the Word Document.  Can we insert it there from the Access VBA or does it have to be built into the templates to start with? If so how, exactly? 

We have tried adding it to the WORD Template, but it does not run – even if we save the document as a .docm re-open it and enable the Marcos.  Even if I copy the VBA for the Project Template into the WORD Document, re-save and re-open it still does not run. I have no idea why not. 

We also have to find some other way of initialising the m_WORDapplication Object, other than in the Document_Open routine. This is because as soon as the WORD Document closes our application thinks the User has finished with the Document and sets about filing it. 

Existing Code

'Acknowledgment:
'---------------
'   This code is a modified version of that found at:
'       http://www.access-programmers.co.uk/forums/showthread.php?t = 153216
'
'   However it has been modified to:
'
'       - confirm to our own variable naming and documentation standards,
'
'       - All subs have been wrapped with:
'               If ActiveDocument.MailMerge.Destination = wdSendToEmail Then
'               ......
'               End If
'         To avoid Errors if user merges to Printer.
'
'       - We have changed the replacement delimiters in the .MailSubject from:
'               <.....>
'         to
'               <<.....>>
'         as this more nearly represents standard MailMerge Field.
'
'       - We explicitly count Mail-Merge DataSource Fields in Document
'               i_NumberOfMergeFields = .DataSource.DataFields.Count
'         and then use a For...Next loop:
'               For i = 1 To i_NumberOfMergeFields
'               .....
'               Next i
'         to control the scanning of:
'               ActiveDocument.MailMerge.DataSource.DataFields(i)
'         as, in our Application, the most likely candidates for substitution are early on,
'         with lower values of i.
'
'       - Included an exit from the For...Next loop to save processing.
'               'If there are no Merge-Fields left in .MailSubject Exit For loop
'               If InStr(1, .MailSubject, "<<") = 0 Then Exit For


'Declaration of Module Level Variables, which are available throughout this Module
'=================================================================================
    Dim WithEvents m_WORDapplication As Application
   
    Dim m_b_WORDapplication_AlreadyOpen As Boolean

    Dim m_s_EmailSubject As String
    Dim m_b_FirstRecord As Boolean


Private Sub Document_Open()
    Set m_WORDapplication = Application
    m_b_WORDapplication_AlreadyOpen = True
    ThisDocument.MailMerge.ShowWizard 6
End Sub


Private Sub m_WORDapplication_MailMergeBeforeMerge(ByVal Doc As Document, ByVal StartRecord As Long, ByVal EndRecord As Long, Cancel As Boolean)
   
    If ActiveDocument.MailMerge.Destination = wdSendToEmail Thenthe
        'Initialise the Module level variable m_b_FirstRecord
        'so that Sub m_WORDapplication_MailMergeBeforeRecordMerge will know it 's dealing with the FirstRecord
        m_b_FirstRecord = True
    End If
   
End Sub


Private Sub m_WORDapplication_MailMergeBeforeRecordMerge(ByVal Doc As Document, Cancel As Boolean)
'
'   Written by: Brian McGuigan
'           of: On2it Software Ltd
'      Version: 1
'        Dated: 26-Mar-14
'First Used in: NEXT Version
'       Status: Tested
'
'      Purpose: This Subroutine changes the ActiveDocument.MailMerge.MailSubject before each Record is merged.
'
'       Method: It does so by replacing any
'                   ActiveDocument.MailMerge.DataSource.DataFields(i).Name
'               it finds in the
'                   .MailSubject
'               delimited by <<.....>> with the corresponding
'                   .DataSource.DataFields(i).Value

    Dim i_NumberOfMergeFields As Integer
    Dim i As Integer
   
    With ActiveDocument.MailMerge
       
        If .Destination = wdSendToEmail Then
   
            If m_b_FirstRecord = True Then
                'Remember .MailSubject complete with Mail-Merge Fields as originally entered with <<.....>>
                m_s_EmailSubject = .MailSubject
                m_b_FirstRecord = False
            Else
                'Reset .MailSubject to so that it still contains the Mail-Merge Fields as entered with <<.....>>
                .MailSubject = m_s_EmailSubject
            End If
   
            'Count Mail-Merge DataSource Fields in Document
            i_NumberOfMergeFields = .DataSource.DataFields.Count
           
            'Replace each Mail-Merge DataSource Field delimited with <<.....>> in .MailSubject
            For i = 1 To i_NumberOfMergeFields
               
                .MailSubject = Replace( _
                    Expression:=.MailSubject, _
                    Find:="<<" & .DataSource.DataFields(i).Name & ">>", _
                    Replace:=.DataSource.DataFields(i).Value, _
                    Compare:=vbTextCompare)
           
                'If there are no Merge-Fields left in .MailSubject Exit For loop
                If InStr(1, .MailSubject, "<<") = 0 Then Exit For
               
            Next i
           
            m_b_FirstRecord = False
       
        End If
       
    End With
   
End Sub


Private Sub m_WORDapplication_MailMergeAfterMerge(ByVal Doc As Document, ByVal DocResult As Document)
    ActiveDocument.MailMerge.MailSubject = m_s_EmailSubject
End Sub


Private Sub Document_Close()
    If ActiveDocument.MailMerge.Destination = wdSendToEmail Then
        Set m_WORDapplication = Nothing
    End If
End Sub

A problem in my code-Regarding bullets and levelled bullets

$
0
0

Hi All,

I have a ribbon button which inserts numbered bullets in my doc like so:

    

private void button4_Click_1(object sender, RibbonControlEventArgs e)
        {

            Word._Document oDoc;
            oDoc = Globals.ThisAddIn.Application.ActiveDocument;
            object oStart = oDoc.Application.Selection.Range.Start;
            object oEnd = oDoc.Application.Selection.Range.End;
             Word.ListGallery listGallery = Globals.ThisAddIn.Application.ActiveDocument.Application.ListGalleries[Word.WdListGalleryType.wdNumberGallery];
             Word.ListFormat listFormat = null;
                  Word.Range rangeInitial = Globals.ThisAddIn.Application.Selection.Range;
                Word.Range range = rangeInitial.Duplicate;
                range.Start = range.End;
                Word.Paragraph oPara;
                 oPara = oDoc.Content.Paragraphs.Add(range);
                 listFormat = oPara.Range.ListFormat;
                this.ApplyListTemplate1(listGallery, listFormat, 1);
                range.ListFormat.ListLevelNumber = 1;
         }

and I have another button which applies levelled numbered bullets like 1.1 ,1.2 etc like this

 private void button5_Click(object sender, RibbonControlEventArgs e)
        {

             Word._Document oDoc;
            oDoc = Globals.ThisAddIn.Application.ActiveDocument;
            object oStart = oDoc.Application.Selection.Range.Start;
            object oEnd = oDoc.Application.Selection.Range.End;


            Word.ListGallery listGallery = Globals.ThisAddIn.Application.ActiveDocument.Application.ListGalleries[Word.WdListGalleryType.wdOutlineNumberGallery];

                Word.Range rangeInitial = Globals.ThisAddIn.Application.Selection.Range;
                Word.Range range = rangeInitial.Duplicate;
                range.Start = range.End;
                Word.Paragraph oPara;
                Word.ListFormat listFormat = null;
                oPara = oDoc.Content.Paragraphs.Add(range);
                  listFormat = oPara.Range.ListFormat;
                this.ApplyListTemplate1(listGallery, listFormat, 2);
                oPara.Range.ListFormat.ListLevelNumber = 2;

            }
Here is my apply list template:  

private void ApplyListTemplate1(Word.ListGallery listGallery, Word.ListFormat listFormat, int level = 2)
        {
            listFormat.ApplyListTemplateWithLevel(
                listGallery.ListTemplates[level],
                ContinuePreviousList: true,
                ApplyTo: Word.WdListApplyTo.wdListApplyToSelection,
                DefaultListBehavior: Word.WdDefaultListBehavior.wdWord10ListBehavior,
                ApplyLevel: level);
        }

 The problem : Here if I click on the level 1 button it inserts a numbered bullet , like "1."  and I click on second btn , it inserts "1.1."  and now if I press the first button to insert "2 ."  it inserts fine,but the second button click does not insert 2.1 ,instead it inserts "1.2" Have been stuck on it for days.Any help is much much appreciated .Thanks                                   

Server hanging out while opening the word object, it is unable to open the word object. but in my devlopment environment, it working fine

$
0
0

                 Microsoft.Office.Interop.Word.Application objWord = new Application();
                WriteEventLog("created word object", "Created new word object");
                    object missing = System.Reflection.Missing.Value;
                    object readOnly = false;
                    object isVisible = false;
                    object fltDocFormat = 10;
                    
                   
                    
                   objWord.Documents.Open(ref uploadedFile, ref readOnly, ref missing, ref missing, ref missing, ref missing,
                   ref missing, ref  missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing,
                   ref missing, ref missing);
                    WriteEventLog("Opened doc", "Opened doc");
                    //Do the background activity

                    objWord.Visible = false;
                   
                   
                    Microsoft.Office.Interop.Word.Document oDoc = objWord.ActiveDocument;
                    WriteEventLog("Created document object", "Created document object");
                    oDoc.SaveAs(ref htmlFile, ref fltDocFormat, ref missing, ref missing, ref missing, ref missing,
                    ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
                    ref missing, ref missing);

 

Server is not responding anything at  below line.

objWord.Documents.Open(ref uploadedFile, ref readOnly, ref missing, ref missing, ref missing, ref missing,
                   ref missing, ref  missing, ref missing, ref missing, ref isVisible, ref missing, ref missing, ref missing,
                   ref missing, ref missing);
where as it is working fine in my local dev environment, some one please help me, it is high priority work item for me

Saving Word file to .doc leaves my .docx corrupt

$
0
0
using Word 2007 and it gives me the option of saving a file to the .doc format instead of .docx. However it gets corrupted and it ends up looking like a notepad file when I open it.

Using Word VBA to add two content controls with a carriage return in between

$
0
0

I'm very comfortable with VBA in Excel, but I'm having trouble with the Word object model. I'm trying to use VBA to add a content control, go down one line, and add another content control. I can get ContentControls.Add to work, and I can get Selection.TypeParagraph to work, but I don't see how to get the carriage return between the two controls.

Thanks,

Dom

Viewing all 4350 articles
Browse latest View live


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