473,569 Members | 2,617 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ungroup shape in word file in c#

70 New Member
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
1 3620
pankajprakash
70 New Member
Got the solution

I have used following code before ungrouping the shape

System.Threadin g.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
1827
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 shape command does not work any more. I have changed the provider and connection string from: pConn->Provider = "MSDataShape"; SAFE_CALL(...
3
2200
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 panels. If the shape is dropped outside any of the panels, I want it to be returned to its original position.
0
1959
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); shape.TextFrame.TextRange.Text = text; Now I want the text to be right-aligned but I can't find a solution!
2
6247
by: Vikas Kumar | last post by:
How to Display the Map from the Shape files in ASP.NET?
0
1921
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 error msg. Anyhow anybody knows if there is any error in its please write to me.I am needed this programme for my assignment. MY CODING : Private...
4
3890
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 lines of code from the GetGeometry method within the CustomPolyLine class: _points.Add(new Point(10, 10));
0
2987
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 VBA code. The following is the Access VBA code I used to delete blank columns and rows in the excel file. But, unfortunately, the resultant excel...
15
2932
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 half then lower half?. Is there a rule that says you can't do it in one set of calculated values for all the points as the points
12
4324
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 from which to start filling. I need to use recursion here. for example, to be clear: input: (ignore the line, think of that as blank space)...
0
7701
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7924
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7677
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.