Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 28th, 2014, 08:35 AM
Registered User
 
Join Date: Oct 2014
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Changing a Shape object's formula changes its format

In Excel 2010 when I change the formula of all shapes on the active sheet to be "=A1", then he format (font, color, etc) of the shapes ALSO change from whatever they were set to to be the same as the format of cell A1. Why is this? How can you just change the formula of the shape without the shape's format also changing to that of the cell referenced by the formula.


Sub FormApp()
Dim Shp As Shape
For Each Shp In ActiveSheet.Shapes
'formula
Shp.DrawingObject.Formula = "=A1"
Next
End Sub
 
Old November 4th, 2014, 01:44 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Can you try if the following works

Code:
 Shp.OLEFormat.Object.Formula = "=A1"
Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old November 4th, 2014, 02:20 AM
Registered User
 
Join Date: Oct 2014
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried this suggestion but it made no difference. The format of the shape changed to that of the A1 cell.

Can I please confirm what your experience is ... that is if you create an Excel 2010 workbook and you create a shape, with a particular format and then you add a formula to the shape to reference the value of another cell whose format is different to the shape's format, does your shape's format change to that of the cell that the formula is targeting, or does it remain unchanged?
 
Old November 5th, 2014, 07:08 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

The format gets aligned to the pointed cell. Using.caption doesn't change the formating but this is not dynamic

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old November 15th, 2014, 12:31 AM
Registered User
 
Join Date: Nov 2014
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

May be something like this is running in the background?

http://www.mrexcel.com/forum/excel-q...e-changes.html
 
Old November 16th, 2014, 05:47 PM
Registered User
 
Join Date: Oct 2014
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have had advice through another forum post that this behaviour is normal for Excel and its shapes. When you change the formula of a shape it changes the format of the shape to that of the cell that the formula is referring to. I had been advised by a third party software development company that I acquired a tool from that this was not the case for at least e2010. It later turned out that the version of e2010 that they were using was a pre-release version and when they upgraded to SP2 they experienced the same behaviour.

Forum post closed. http://answers.microsoft.com/en-us/o...=1415099885822

This thread can now be closed from my point of view.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in changing date format pannasn Crystal Reports 2 December 15th, 2007 12:26 AM
Changing ReleaseDate and ExpireDate format dojdod BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 April 22nd, 2007 10:02 AM
Rotating shape in VBA (not center of shape) Piblon Excel VBA 3 April 13th, 2006 04:04 AM
Formula to convert date format narooma.12 Crystal Reports 0 April 20th, 2005 04:54 PM
Changing format for Dynamic Text . joshil Access ASP 1 April 20th, 2004 08:19 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.