473,322 Members | 1,403 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,322 software developers and data experts.

Text Font Size

142 100+
How to change the textbox text size in visio using vb6? is something like the follow? but it seem not work, anybody help?

Dim ashape As Shape
ashape.Text.Font = New Font("Times New Roman", 22)
Mar 5 '07 #1
24 9352
Killer42
8,435 Expert 8TB
Try this:
Expand|Select|Wrap|Line Numbers
  1. ashape.Text.Font.Size = 22
Mar 6 '07 #2
vijaydiwakar
579 512MB
How to change the textbox text size in visio using vb6? is something like the follow? but it seem not work, anybody help?

Dim ashape As Shape
ashape.Text.Font = New Font("Times New Roman", 22)
u've given the code related to .net
in vb6 use font. property name
Mar 6 '07 #3
joemo2003
142 100+
Try this:
Expand|Select|Wrap|Line Numbers
  1. ashape.Text.Font.Size = 22

"ashape.Text=xxx" do output "xxx" to my visio drawing with default text size of 12, but when i try "ashape.Text.Font.Size=22", it selected the "Text" and come out "compile error invalid qualifier". Do any one know what is happening?

Thanks
Mar 6 '07 #4
Killer42
8,435 Expert 8TB
"ashape.Text=xxx" do output "xxx" to my visio drawing with default text size of 12, but when i try "ashape.Text.Font.Size=22", it selected the "Text" and come out "compile error invalid qualifier". Do any one know what is happening?
Try leaving out "Text". That is, ashape.Font.Size=22.
Mar 6 '07 #5
joemo2003
142 100+
Try leaving out "Text". That is, ashape.Font.Size=22.
Same error message with "ashape" got selected. Do you know when that will happen?

thanks much
Mar 7 '07 #6
Killer42
8,435 Expert 8TB
Same error message with "ashape" got selected. Do you know when that will happen?
Are you sure that ashape exists? What type is it?
Mar 7 '07 #7
joemo2003
142 100+
Are you sure that ashape exists? What type is it?
Here is my basic code:
Dim adoc As Document, amaster As Master
Dim apage As Page, ashape As Shape
Set apage = ActivePage
Set adoc = Documents("basic shapes.vss")
'draw a rectangle textbox to visio
Set amaster = adoc.Masters("rectangle")
'set the textbox's location
Set ashape = apage.Drop(amaster, 3, 4)
ashape.Text =XXX
ashape.Text.Font.size=22

everything except the font size work fine, any ideal?

Thanks
Mar 8 '07 #8
Killer42
8,435 Expert 8TB
In VB6, the Shape object does not have a Font property. Or a Text property. I don't get it. Do the Visio objects somehow replace the built-in ones?
Mar 8 '07 #9
SammyB
807 Expert 512MB
I don't have Visio on any of my current computers, but I think you have to create a Cell and then change the font. Something like
Dim ashape As Visio.Shape ' Always qualify your Visio variables
Dim vsoCell As Visio.Cell
Set vsoCell = ashape.Cells("Char.Size")
vsoCell.Formula = "=22 pt."
Nothing is easy in Visio! HTH --Sam

Here is my basic code:
Dim adoc As Document, amaster As Master
Dim apage As Page, ashape As Shape
Set apage = ActivePage
Set adoc = Documents("basic shapes.vss")
'draw a rectangle textbox to visio
Set amaster = adoc.Masters("rectangle")
'set the textbox's location
Set ashape = apage.Drop(amaster, 3, 4)
ashape.Text =XXX
ashape.Text.Font.size=22

everything except the font size work fine, any ideal?

Thanks
Mar 8 '07 #10
SammyB
807 Expert 512MB
Found a Visio machine, but VB6 is long gone, so I faked it with Excel VBA. Here's what it should look like:
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Private vsApp As Visio.Application
  3.  
  4. Sub BtnStart_Click()
  5.     Dim vsDoc As Visio.Document
  6.     Set vsApp = CreateObject("Visio.Application")
  7.     Set vsDoc = vsApp.Documents.Add("basic shapes.vss")
  8. End Sub
  9.  
  10. Sub BtnDrop_Click()
  11.     Dim vsDoc As Visio.Document
  12.     Dim vsMaster As Visio.Master
  13.     Dim vsPage As Visio.Page
  14.     Dim vsShape As Visio.Shape
  15.     Dim vsCell As Visio.Cell
  16.     Set vsDoc = vsApp.ActiveDocument
  17.     Set vsPage = vsDoc.Pages(1)
  18.     vsPage.OpenDrawWindow
  19.     vsApp.Windows.Arrange visArrangeTileVertical
  20.     Set vsMaster = vsDoc.Masters("rectangle")
  21.     Set vsShape = vsPage.Drop(vsMaster, 3, 4)
  22.     vsShape.Text = "Hi!"
  23.     Set vsCell = vsShape.Cells("Char.Size")
  24.     vsCell.Formula = "=22 pt."
  25.     Set vsCell = Nothing
  26.     Set vsShape = Nothing
  27.     Set vsPage = Nothing
  28.     Set vsMaster = Nothing
  29. End Sub
  30.  
  31. Sub BtnClose_Click()
  32.     Dim vsDoc As Visio.Document
  33.     Set vsDoc = vsApp.ActiveDocument
  34.     vsDoc.SaveAs "MyTestVisioDoc.vsd"
  35.     vsApp.Quit
  36.     Set vsDoc = Nothing
  37.     Set vsApp = Nothing
  38. End Sub
Mar 9 '07 #11
joemo2003
142 100+
In VB6, the Shape object does not have a Font property. Or a Text property. I don't get it. Do the Visio objects somehow replace the built-in ones?
I am not sure, but it work.
Mar 12 '07 #12
joemo2003
142 100+
Found a Visio machine, but VB6 is long gone, so I faked it with Excel VBA. Here's what it should look like:
Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Private vsApp As Visio.Application
  3.  
  4. Sub BtnStart_Click()
  5.     Dim vsDoc As Visio.Document
  6.     Set vsApp = CreateObject("Visio.Application")
  7.     Set vsDoc = vsApp.Documents.Add("basic shapes.vss")
  8. End Sub
  9.  
  10. Sub BtnDrop_Click()
  11.     Dim vsDoc As Visio.Document
  12.     Dim vsMaster As Visio.Master
  13.     Dim vsPage As Visio.Page
  14.     Dim vsShape As Visio.Shape
  15.     Dim vsCell As Visio.Cell
  16.     Set vsDoc = vsApp.ActiveDocument
  17.     Set vsPage = vsDoc.Pages(1)
  18.     vsPage.OpenDrawWindow
  19.     vsApp.Windows.Arrange visArrangeTileVertical
  20.     Set vsMaster = vsDoc.Masters("rectangle")
  21.     Set vsShape = vsPage.Drop(vsMaster, 3, 4)
  22.     vsShape.Text = "Hi!"
  23.     Set vsCell = vsShape.Cells("Char.Size")
  24.     vsCell.Formula = "=22 pt."
  25.     Set vsCell = Nothing
  26.     Set vsShape = Nothing
  27.     Set vsPage = Nothing
  28.     Set vsMaster = Nothing
  29. End Sub
  30.  
  31. Sub BtnClose_Click()
  32.     Dim vsDoc As Visio.Document
  33.     Set vsDoc = vsApp.ActiveDocument
  34.     vsDoc.SaveAs "MyTestVisioDoc.vsd"
  35.     vsApp.Quit
  36.     Set vsDoc = Nothing
  37.     Set vsApp = Nothing
  38. End Sub

Thanks, all i need is add the follow to my code.
Set vsCell = vsShape.Cells("Char.Size")
vsCell.Formula = "=22 pt."
Mar 12 '07 #13
SammyB
807 Expert 512MB
Thanks, all i need is add the follow to my code.
Set vsCell = vsShape.Cells("Char.Size")
vsCell.Formula = "=22 pt."
Visio must be very forgiving! Notice that you get the page before you get the document. Also, most of Object Libraries have Application, Document and Shape objects so you really need to prefix you declarations with Visio. Speaking from experience, VB lets you get away with way too much sloppy code.
Mar 12 '07 #14
joemo2003
142 100+
Visio must be very forgiving! Notice that you get the page before you get the document. Also, most of Object Libraries have Application, Document and Shape objects so you really need to prefix you declarations with Visio. Speaking from experience, VB lets you get away with way too much sloppy code.

Seem you know Visio a lot. can you help me on one more thing? I try to create a commandbuttom1 in visio VBA, when i click that buttom it will open the Opendialog box to browse and open a excel file, that Opened excel file name will use as "XXX" in the code below. And when i click the commandbutton2 it will inport the excel data in visio. What i don't get is how to write the code for commandbutton1. In excel VBA we can use "Application.Dialogs(xldialogopen).Show", and in visio I find something "MsoOpenfile". Can you help me how to use it?


Private Sub CommandButton1_Click()
???
'need to open a excel file.
End Sub

Private Sub CommandButton2_Click()
Dim xlObjApp As Excel.Application
Dim xlObjBook As Excel.Workbook
Dim xlObjSheet As Excel.Worksheet
Set xlObjApp = GetObject(, "Excel.Application")
Set xlObjBook = xlObjApp.Workbooks.Item("XXX.xls")
Set xlObjSheet = xlObjBook.Worksheets.Item("Sheet1")
TextBox1 = xlObjSheet.Cells(1, 1)
Mar 12 '07 #15
SammyB
807 Expert 512MB
Seem you know Visio a lot...
Yes, I can help, but actually, that was my first Visio program. ;o)>>>

It should be the same as Excel, but Excel is done like https://bytes.com/showthread.php?t=614371. Try using the same objects in Visio. If that doesn't work, I can try to do that tomorrow. I'll have Visio on tomorrow's computer.
Mar 12 '07 #16
joemo2003
142 100+
thanks, but i still don't know how to open a Open Dialogbox to browse a file by a click even in visio VBA.


Yes, I can help, but actually, that was my first Visio program. ;o)>>>

It should be the same as Excel, but Excel is done like https://bytes.com/showthread.php?t=614371. Try using the same objects in Visio. If that doesn't work, I can try to do that tomorrow. I'll have Visio on tomorrow's computer.
Mar 13 '07 #17
SammyB
807 Expert 512MB
thanks, but i still don't know how to open a Open Dialogbox to browse a file by a click even in visio VBA.
Well, Visio is annoying! First of all, ignore my post "It should be the same as Excel" and the link to inserting a button & code. I cannot get this to work for Visio: the Page object has an OLEObjects collection, but it is readonly.

But happily, I don't think that that is really what you wanted to do. From your post in MSDN, it looks like you want to open an Excel file from a Visio macro. So, I thought, "That's easy, just do an Office.FileDialog." NOT easy, Visio does not appear to have FileDialog. I would rant at MS for that, but it is pointless.

So, I had a good idea: since you are wanting to use Excel, why not open the Excel application and use its GetOpenFileName, so I've done that in the code snippet below. If you need more help get the data from Excel, just ask, Excel is easy. (Don't forget to add a reference in your Visio drawing to MS Excel Objects.)

Finally, I discovered these Visio Customization pages on MSDN. They look difficult, but may give you more ideas. See http://msdn2.microsoft.com/en-us/lib...ffice.10).aspx

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2.  
  3. Sub GetXlData()
  4.     'Open Excel
  5.     Dim xlApp As Excel.Application
  6.     Set xlApp = New Excel.Application
  7.     xlApp.Visible = True
  8.  
  9.     'Get Excel filename & open it
  10.     Dim vFile As Variant
  11.     vFile = xlApp.GetOpenFilename( _
  12.         "Excel Workbooks(*.xls),*.xls,All Files(*.*),*.*", _
  13.         1, "Select Workbook")
  14.     If vFile <> False Then
  15.         Dim xlBook As Excel.Workbook
  16.         Set xlBook = xlApp.Workbooks.Open(vFile)
  17.     End If
  18. End Sub
Mar 13 '07 #18
joemo2003
142 100+
i got another question, what is the most easy way to add an icon to the visio toolbar that can run the macro by just click that icon? someting like compile to .ocx, can it compile in visio VB editor?
Mar 13 '07 #19
SammyB
807 Expert 512MB
i got another question, what is the most easy way to add an icon to the visio toolbar that can run the macro by just click that icon? someting like compile to .ocx, can it compile in visio VB editor?
Please read the link I posted, it's all in there (including toolbars) and it's all different from evey other Office product. Again, study http://msdn2.microsoft.com/en-us/lib...e.10).aspx#624
Mar 13 '07 #20
joemo2003
142 100+
Please read the link I posted, it's all in there (including toolbars) and it's all different from evey other Office product. Again, study http://msdn2.microsoft.com/en-us/lib...e.10).aspx#624
Thanks a lot, the command buttom code above is what I looking for. I still cannot find a way to create COM add-in, it could be great if you give me a hand again.

I have read through that webpage and search a lot online. Since i don't have the software such as visual basic and visual studio, and i saw the only way to create COM add-ins is use VBA with Microsoft Office Developer (version 2000 or later).
http://msdn2.microsoft.com/en-us/library/aa201798(office.10).aspx
and i have download the COM add-in designer for Visio, http://www.microsoft.com/downloads/details.aspx?FamilyID=a8c53c83-0624-43dd-9bd4-ae06494a7dbc&DisplayLang=en

but the problem come out, it saiding:"To use the Microsoft(r) Visio(r) COM Addin Designer, copy the following files into the Projects directory for your installation of Microsoft Visual Basic 6..."

Do you know how that COM desginer work?
Mar 13 '07 #21
SammyB
807 Expert 512MB
Thanks a lot, the command buttom code above is what I looking for. I still cannot find a way to create COM add-in, it could be great if you give me a hand again.

I have read through that webpage and search a lot online. Since i don't have the software such as visual basic and visual studio, and i saw the only way to create COM add-ins is use VBA with Microsoft Office Developer (version 2000 or later).
http://msdn2.microsoft.com/en-us/library/aa201798(office.10).aspx
and i have download the COM add-in designer for Visio, http://www.microsoft.com/downloads/details.aspx?FamilyID=a8c53c83-0624-43dd-9bd4-ae06494a7dbc&DisplayLang=en

but the problem come out, it saiding:"To use the Microsoft(r) Visio(r) COM Addin Designer, copy the following files into the Projects directory for your installation of Microsoft Visual Basic 6..."

Do you know how that COM desginer work?
No I do noy know how that designer works. I have created Com Addins for Excel, but have never programmed Viso nor used the files you downloaded. I do not think that you want to develope a COM Addin. Even simple COM Addins are difficult: I gave an A to a beginning VBstudent and all that he did was copy an example from a book (with my permission). If you have lots of time, you would want to do the following:
  1. Buy the book, Microsoft Office XP Developer's Guide. (note--it never mentions Visio)
  2. While at the bookstore buy anything that talks about Visio programming
  3. Do all of the COM Addin examples in the Office XP book. There are about 30 pages of them, but nothing for Visio.
  4. Search MSDN for anything about Visio COM Addins
  5. Apply what you have learned to create the simplest COM Addin that you can think of. Just one button & one routine that the button calls.
  6. Be very patient and meticulous
Mar 13 '07 #22
joemo2003
142 100+
Thanks a lot, I will try to figure out by myself. Actually I am not doing it for class, I am doing for my intern project. The bad thing is I am not major in anyting related with CS. Can I ask you a final question? It relate with the open command you help me before. I need to import some data to visio from excel after opened the excel file, the code is below, but "XXX.xls" in the code must be the name of the excel file name, and it won't work If i need data from another excel file. How to change the code so I can just import the data from the Opened excel by CommandBotton1?


Sub CommandButton2_Click()
Dim xlObjApp As Excel.Application
Dim xlObjBook As Excel.Workbook
Dim xlObjSheet As Excel.Worksheet
Dim xlObjCell As Excel.Range
Set xlObjApp = New Excel.Application
xlObjApp.Visible = False
Set xlObjApp = GetObject(, "Excel.Application")
Set xlObjBook = xlObjApp.Workbooks.Item("XXX.xls")
Set xlObjSheet = xlObjBook.Worksheets.Item("Sheet1")
...
TextBox1 = xlObjSheet.Cells(1, 1)
...


No I do noy know how that designer works. I have created Com Addins for Excel, but have never programmed Viso nor used the files you downloaded. I do not think that you want to develope a COM Addin. Even simple COM Addins are difficult: I gave an A to a beginning VBstudent and all that he did was copy an example from a book (with my permission). If you have lots of time, you would want to do the following:
  1. Buy the book, Microsoft Office XP Developer's Guide. (note--it never mentions Visio)
  2. While at the bookstore buy anything that talks about Visio programming
  3. Do all of the COM Addin examples in the Office XP book. There are about 30 pages of them, but nothing for Visio.
  4. Search MSDN for anything about Visio COM Addins
  5. Apply what you have learned to create the simplest COM Addin that you can think of. Just one button & one routine that the button calls.
  6. Be very patient and meticulous
Mar 14 '07 #23
SammyB
807 Expert 512MB
<snip> I need to import some data to visio from excel after opened the excel file, the code is below, but "XXX.xls" in the code must be the name of the excel file name, and it won't work If i need data from another excel file. How to change the code so I can just import the data from the Opened excel by CommandBotton1?<snip>
Please look at the code in post #18, http://www.thescripts.com/forum/post2432069-18.html, isn't that what you want to do?

However, if you want to have Excel already open, then just use xlObjApp.ActiveWorkbook or skip that book line and
Set xlObjSheet = xlObjApp.ActiveSheet
Mar 14 '07 #24
joemo2003
142 100+
Please look at the code in post #18, http://www.thescripts.com/forum/post2432069-18.html, isn't that what you want to do?

However, if you want to have Excel already open, then just use xlObjApp.ActiveWorkbook or skip that book line and
Set xlObjSheet = xlObjApp.ActiveSheet
Thanks a lot, finally finish this project. :)
Mar 14 '07 #25

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

Similar topics

2
by: jaydog | last post by:
Hello... I'm new to XSL, and I've written a XSLT file that converts a XML file to HTML format. When viewed in a browser, it appears exactly as I would like. However, if I want to look at the...
0
by: Quinton | last post by:
I'm running a website that uses CSS to format the text and a CGI program Coranto that icludes news updates via SSI. My problem is that some parts of the CSS don't seem to take effect on the...
19
by: dmiller23462 | last post by:
Hi guys....I have absolutely NO IDEA what I'm doing with Javascript but my end result is I need two text boxes to stay hidden until a particular option is selected....I've cobbled together the...
4
by: Arif Çimen | last post by:
Hi to everybody, I have chnged a button text in design mode. But After compiling and executing the program the text of the button do not change to new value. Any Ideas? Thaks for helps.
15
by: phillip.s.powell | last post by:
<style> div div table tr td a.navbar, div div table tr td font {display: none;} </style> <div class="navigationbar" style="background-color:Black; position: absolute; left:50%; top:127px;...
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin,...
13
by: =?Utf-8?B?S2VzdGZpZWxk?= | last post by:
Hi Our company has a .Net web service that, when called via asp.net web pages across our network works 100%! The problem is that when we try and call the web service from a remote machine, one...
3
by: kibong | last post by:
I am trying to get what the user inputs into the box and then take that to check their answers and make sure everything is correct before moving on. here is my code <%@ Page Language="vb" %> ...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
7
by: kirkgilbert | last post by:
I am trying to do an onchange event in a form using a text field. The form is tied to a record set that is part of a repeated region. One the first record when I edit the data it works perfectly. ...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.