|
-
Aug 21st, 2008, 12:26 PM
#1
Thread Starter
Member
[RESOLVED] Format in excel 2007
In previous versions of excel I was able to format the contents of a cell by using Format() (ex. Format(A1.Value, "0.00%") to turn the value of cell a1 into a percentage. But in the 2007 version of excel I get an error that the project or library cannot be found. Does anyone know which reference I should add to get this to work?
thanks
-
Aug 21st, 2008, 12:37 PM
#2
Re: Format in excel 2007
It works for me so you may have lost a reference. Was this workbook previously created in 2003 or before?
Visual Basic for Applications
Microsoft Excel 12.0 Object Library
OLE Automation
Microsoft Office 12.0 Object Library
At a minimum you should have those.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 21st, 2008, 12:45 PM
#3
Thread Starter
Member
Re: Format in excel 2007
I have all 4 of those. And yes it was created in 2003.
-
Aug 21st, 2008, 09:14 PM
#4
Re: Format in excel 2007
Maybe your reference is corrupt.
Try creating a new workbook and save it as 2003 fileformat. Then open the vba ide and try your code.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 21st, 2008, 11:40 PM
#5
Re: Format in excel 2007
Check to see if it has any bad reference with the word "MISSING:".
Beside that, to format a cell you should use .NumberFormat property of Range, that is a better way:
Sheet1.Range("A1").NumberFormat = "0.00%"
Noted that Format(Range("A1"), "0.00") returns a String that looks like a number, so it convert number to text then in cell that text may be converted back to number if the cell has "General" format.
-
Aug 22nd, 2008, 02:09 AM
#6
Re: Format in excel 2007
Format is in the "Visual Basic for Applications" library reference. Its a core reference of Excel/Office so it can not be removed and shouldnt show "MISSING". It can get corrupt which more then likely be your issue.
Did you try checking a new workbook like I suggested? If it doesnt work in new then its probably the corrupt reference.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Aug 22nd, 2008, 03:13 AM
#7
Re: Format in excel 2007
 Originally Posted by RobDog888
Format is in the "Visual Basic for Applications" library reference. Its a core reference of Excel/Office so it can not be removed and shouldnt show "MISSING". It can get corrupt which more then likely be your issue.
Agee with that, however, it looks like the same sympton with Chr() and orther core functions when one of other library MISSING, the compiler may confuse. I have seen this before when I open someone's workbook with a missing library even that is not used in the code at all, I just uncheck that MISSING library then it works. That maybe or maybe not in this case, but just have a check.
-
Aug 22nd, 2008, 09:35 AM
#8
Thread Starter
Member
Re: Format in excel 2007
Thanks anhn,
I did have a "MISSING" reference. When I removed it, the problem went away.
-
Aug 22nd, 2008, 05:38 PM
#9
Re: Format in excel 2007
 Originally Posted by primfran
Thanks anhn,
I did have a "MISSING" reference. When I removed it, the problem went away.
Glad to see that my experience about the "MISSING" can help in this case.
-
Aug 22nd, 2008, 08:51 PM
#10
Re: [RESOLVED] Format in excel 2007
 Originally Posted by Robdog888
... you may have lost a reference.
Glad its settled then
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|