473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Ungroup shape in word file in c#

Hi, I have a word file which contains numbers of shapes. Each shape contain some textboxes. I am copying that file to another location and assigning some values to those textboxes of those shapes. Now I have to assign the values to those textboxes then I have to ungroup those shape first then only I can assign values those text boxes. Now the problem is that when I ungroup those shapes, they change their locations in the document. I do not understand what is the problem. Here is the code
Expand|Select|Wrap|Line Numbers
  1. //copy the sourc file to another location
  2. System.IO.File.Copy(Convert.ToString(source), Convert.ToString(destination));
  3.  
  4. Microsoft.Office.Interop.Word.Document obDoc = new Microsoft.Office.Interop.Word.Document();
  5.  
  6. object unknown = Type.Missing;
  7. object format = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatDocumentDefault;
  8. obDoc = varWord.Documents.Add(ref source, ref unknown, ref unknown, ref visible);
  9.  
  10. obDoc.Activate();
  11.  
  12. //hiding a shape--working fine
  13. obj = "shape1";
  14. varWord.ActiveDocument.Shapes.get_Item(ref obj).Select(ref unknown);
  15. varWord.ActiveDocument.Shapes.get_Item(ref obj).Visible = MsoTriState.msoFalse;
  16.  
  17.  
  18. //ungroup the shape
  19. obj = "Shape2";
  20. varWord.ActiveDocument.Shapes.get_Item(ref obj).Select(ref unknown);
  21. varWord.ActiveDocument.Shapes.get_Item(ref obj).Ungroup();
  22.  
  23.  
  24. obj = "txtbox1";
  25. varWord.ActiveDocument.Shapes.get_Item(ref obj).Select(ref unknown);
  26. varWord.Selection.TypeText(txtbox1value);
  27.  
  28. //show the word file
  29. varWord.Visible = true;
  30. varWord = null;
  31.  
  32.  
:(
Nov 23 '09 #1

✓ answered by pankajprakash

Got the solution

I have used following code before ungrouping the shape

System.Threading.Thread.Sleep(1000);


Actually when c# code run its ungroup the shape first, then render the file, that's why shape is showing in the header of the page, not in the proper position. Now using the sleep method it renders the shape in proper place.

1 3596
Got the solution

I have used following code before ungrouping the shape

System.Threading.Thread.Sleep(1000);


Actually when c# code run its ungroup the shape first, then render the file, that's why shape is showing in the header of the page, not in the proper position. Now using the sleep method it renders the shape in proper place.
Nov 23 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: minjie | last post by:
Hello, I have several reports that were written with ADO shape command (in C++) to access Microsoft Access database. Now we have migrated all the data from Access to DB2 UDB (version 8.1), and the...
3
by: PM | last post by:
Hi, Im a student currently designing a game for a project. As part of my game, I want to be able to drag a shape over a series of panels. The shape needs to be able to be dropped on any of the...
0
by: nets-rac | last post by:
Hi, I use c# to automate powerpoint. I created a new shape with PowerPoint.Shape shape = slide.Shapes.AddTextbox(MsoTextOrientation.msoTextOrientationHorizontal, left, top, width, height);...
2
by: Vikas Kumar | last post by:
How to Display the Map from the Shape files in ASP.NET?
0
by: saravanansvks | last post by:
Dear Friends, I have prepared a programme in Visual Basic for SHAPE OPERATOR.But my coding are changing the shape only.It does not changes the fill style of the shape tool .And it is not giving ant...
4
by: Linda Liu[MSFT] | last post by:
Hi Moondaddy, I downloaded your sample project and run it and did see the problem on my side. There're three problems in the source code of your project. 1. You should move the following...
0
by: JFKJr | last post by:
I have an excel file, which has columns C and D grouped together, I am trying to delete blank columns and rows from the excel file, ungroup the columns and import the file to MS Access using Access...
15
by: bH | last post by:
Hi All, I have been looking at javascript drawing from this website : http://www.cwdjr.net/geometricDraw/pentagon_draw.html" and I am wondering why the author made it into two images : upper...
12
by: ab12 | last post by:
I'm trying to write a program in C that gets a shape outlined with asterisks from the user, and returns that shape filled with asterisks. It will also get the coordinates of a point inside the shape...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.