I use the follow code to resize the textbox in visio, anybody know what is wrong? -
Dim ashape as visio.shape
-
ashape.CellsU("TxtWidth").Formula = "=TEXTWIDTH(TheText)"
-
Thanks
40 5382
or I want to maximize the textbox, so -
ashape.Formula = "Max(TEXTWIDTH(TheText), 8 * Char.Size)"
-
Any help on either way will be great.
or I want to maximize the textbox, so -
ashape.Formula = "Max(TEXTWIDTH(TheText), 8 * Char.Size)"
-
Any help on either way will be great.
seem like the ashape.Formula is wrong.
seem like the ashape.Formula is wrong.
that is wrong.
that is wrong.
Samm help.
Forget everthing above, -
Dim celObjWidth As Visio.Cell
-
Set celObjWidth = ashape.Cells("width")
-
If ashape.Text = sFind Then
-
ashape.Text = sFind & Chr(10) & sReplacement
-
End if
-
celObjWidth.Formula = "=GUARD(TEXTWIDTH(TheText))"
-
this code actually work, but not only resize the textbox, but also resize all the other shape.
help
Samm help.
:) No Visio untill tonight, 9PM EST. Can't you just record a macro in Visio that does the resize and look at the code that it generates?
samm,
when you have visio with you, could you test another thing for me too.
I need to input text to visio with mutiple pages, the follow code is working for me -
For k=1 To 5
-
Set apage = vsDoc.Pages(k)
-
...
-
Next k
-
The thing is the code above need to tell the page number (5), but the page may be varied on other visio files, is there a code something like
vsDoc.Pages(End)?
thanks
samm,
when you have visio with you, could you test another thing for me too.
I need to input text to visio with mutiple pages, the follow code is working for me -
For k=1 To 5
-
Set apage = vsDoc.Pages(k)
-
...
-
Next k
-
The thing is the code above need to tell the page number (5), but the page may be varied on other visio files, is there a code something like
vsDoc.Pages(End)?
thanks
For width & height, this works for me: - If s.Text = sFind Then
-
s.Text = sReplacement
-
s.Cells("Height").Formula = "40mm"
-
s.Cells("Width").Formula = "60mm"
-
End If
For number of pages, just use Pages.Count: - MsgBox vsDoc.Pages.Count
-
Set vsLastPage = vsDoc.Pages(vsDoc.Pages.Count)
Do u still remember the resize text font you help me before? -
ashape.Text = sFind & Chr(10) & sReplacement
-
This time I only want to resize the sReplacement, but not the sFind,
If i use -
Dim aCell As Visio.Cell
-
Set aCell = ashape.Text("Char.size")
-
aCell.Formula="12pt"
-
it will resize include the sFind. So how to resize partially?
thanks
Do u still remember the resize text font you help me before? -
ashape.Text = sFind & Chr(10) & sReplacement
-
This time I only want to resize the sReplacement, but not the sFind,
If i use -
Dim aCell As Visio.Cell
-
Set aCell = ashape.Text("Char.size")
-
aCell.Formula="12pt"
-
it will resize include the sFind. So how to resize partially?
thanks
You use the Characters object: - Dim s As String, i As Integer
-
s = "Not Fun"
-
Dim c As Characters
-
Set c = ActivePage.Shapes(1).Characters
-
i = InStr(c.Text, s)
-
c.Begin = i - 1
-
c.End = i - 1 + Len(s)
-
c.CharProps(visCharacterSize) = 16
-
c.CharProps(visCharacterStyle) = visBold + visItalic
-
c.CharProps(visCharacterColor) = visRed
In this example, "Not Fun" is your replacement text. It is set to 16 point, bold, italic, & red. HTH --Sam
Also, a book: Learn Microsoft Visio 2002 for the Advanced User by Ralph Grabowski and Frank Zander
You use the Characters object: - Dim s As String, i As Integer
-
s = "Not Fun"
-
Dim c As Characters
-
Set c = ActivePage.Shapes(1).Characters
-
i = InStr(c.Text, s)
-
c.Begin = i - 1
-
c.End = i - 1 + Len(s)
-
c.CharProps(visCharacterSize) = 16
-
c.CharProps(visCharacterStyle) = visBold + visItalic
-
c.CharProps(visCharacterColor) = visRed
In this example, "Not Fun" is your replacement text. It is set to 16 point, bold, italic, & red. HTH --Sam
I use -
For Each ashape In apage.Shapes
-
...
-
Set c = ashape.Characters
-
...
-
next ashape
-
when I debug it, that "ashape.Characters" return nothing. It said "type mismatch". Why is that happen?
I use -
For Each ashape In apage.Shapes
-
...
-
Set c = ashape.Characters
-
...
-
next ashape
-
when I debug it, that "ashape.Characters" return nothing. It said "type mismatch". Why is that happen?
Well, the "ashape.Characters" do return something, but the "c" is empty.
Well, the "ashape.Characters" do return something, but the "c" is empty.
Remember, you are in a multiple application world (Excel & Visio). c should be Dim'ed as Visio.Characters. My sample was just a Visio macro. Keep :)!
Remember, you are in a multiple application world (Excel & Visio). c should be Dim'ed as Visio.Characters. My sample was just a Visio macro. Keep :)!
great, that work. One more question, how to use the SaveAsEx function?
I try to save the same file name with extension date and time, but all I know is use the vsDoc.save or vsApp.DoCmd(visCmdFileSave).
great, that work. One more question, how to use the SaveAsEx function?
I try to save the same file name with extension date and time, but all I know is use the vsDoc.save or vsApp.DoCmd(visCmdFileSave).
- Dim sNew As String
-
sNew = Split(ActiveDocument.Name, ".")(0) ' Strip filetype
-
sNew = sNew & "-" & Format(Now(), "yyyy-mm-dd") & ".vsd"
-
MsgBox "Saving chart as readonly in " & sNew
-
ActiveDocument.SaveAsEx sNew, visSaveAsRO
great, everthing work good. hopefully my boss will like it. Thanks, sam
I think the use the DoCmd to open visio is simpler than the one you help me before. -
Set vsApp = New Visio.Application
-
vsApp.DoCmd (visCmdFileOpen)
-
the code work for select and open the visio, but error occur when click cancel.
How can I make the cancel work too?
I think the use the DoCmd to open visio is simpler than the one you help me before. -
Set vsApp = New Visio.Application
-
vsApp.DoCmd (visCmdFileOpen)
-
the code work for select and open the visio, but error occur when click cancel.
How can I make the cancel work too?
It's not simpler if it doesn't work. Use Excel.GetOpenFilename and make the response a Variant. If the user presses Cancel, then the Variant is False. Weird, but standard Microsoft: - Dim vFile As Variant
-
vFile = Application.GetOpenFilename("All Visio Files (*.vs*;*.v?x), *.vs*;*.v?x")
-
If vFile = False Then Exit Sub
-
MsgBox "Open Visio file, " & vFile
-
You can get DoCmd to work, but it's not pretty. - Dim vsApp As Visio.Application
-
Dim vsDoc As Visio.Document
-
Set vsApp = CreateObject("Visio.Application")
-
On Error GoTo PressedCancel
-
vsApp.DoCmd (visCmdFileOpen)
-
On Error GoTo 0 ' Resume normal error processing
-
Set vsDoc = vsApp.ActiveDocument
-
MsgBox "Continue Processing..."
-
Exit Sub
-
PressedCancel:
-
vsApp.Quit
-
It's not simpler if it doesn't work. Use Excel.GetOpenFilename and make the response a Variant. If the user presses Cancel, then the Variant is False. Weird, but standard Microsoft: - Dim vFile As Variant
-
vFile = Application.GetOpenFilename("All Visio Files (*.vs*;*.v?x), *.vs*;*.v?x")
-
If vFile = False Then Exit Sub
-
MsgBox "Open Visio file, " & vFile
-
You can get DoCmd to work, but it's not pretty. - Dim vsApp As Visio.Application
-
Dim vsDoc As Visio.Document
-
Set vsApp = CreateObject("Visio.Application")
-
On Error GoTo PressedCancel
-
vsApp.DoCmd (visCmdFileOpen)
-
On Error GoTo 0 ' Resume normal error processing
-
Set vsDoc = vsApp.ActiveDocument
-
MsgBox "Continue Processing..."
-
Exit Sub
-
PressedCancel:
-
vsApp.Quit
-
The reason I want to use the DoCmd is it pass te fully path and filename to the opened file, but GetOpenFilename does not. Thanks a lot, that DoCmd is working now.
Sam, help again.
In commondbutton1, I have -
Dim vsDocs As Visio.Documents
-
Dim vsDoc As Visio.Document
-
Set vsDocs = vsApp.Documents
-
Set vsDoc = vsDocs.Open("D:\folderxx\test.vsd")
-
Set vsDoc = vsApp.ActiveDocument
-
vsApp.Visible = False
-
in commondbutton 2, I have -
sNew = Split(vsDoc.Name, ".")(0)
-
sNew = sNew & "(" & Format(Now(), "MM_dd_yyyy") & ".vsd"
-
vsApp.ActiveDocument.SaveAsEx sNew, visSaveAsRO
-
vsApp.quit
-
When it save the file, it lost the path and save to a temporally folder in C: drive, how to make it save to where the file come from (the D: drive)? It save back to D: drive when I use the DoCmd(visCmdFileOpen), but this time I need to specified the file name in the code.
Visio.ActiveDocument.Path
Visio.ActiveDocument.Path
I still cannot figure out how to use the path function. can you specify little bit more?
I still cannot figure out how to use the path function. can you specify little bit more?
Putting the Open/Close all together, I have: - Sub OpenExisting()
-
Dim vsApp As Visio.Application
-
Dim vsDoc As Visio.Document
-
Set vsApp = CreateObject("Visio.Application")
-
On Error GoTo PressedCancel
-
vsApp.DoCmd (visCmdFileOpen)
-
On Error GoTo 0 ' Resume normal error processing
-
Set vsDoc = vsApp.ActiveDocument
-
MsgBox "Continue Processing..."
-
Dim sNew As String
-
sNew = Split(vsDoc.Name, ".")(0)
-
sNew = sNew & "-" & Format(Now(), "MM_dd_yyyy") & ".vsd"
-
vsApp.ActiveDocument.SaveAsEx vsDoc.Path & sNew, visSaveAsRO
-
vsApp.Quit
-
PressedCancel:
-
vsApp.Quit
-
End Sub
Is that clear or is there something that needs explanation? BTW When you run a macro, you can press the "Step Into" button and step through your code with the F8 key. As you step through it, when you hover the mouse over a property or variable, the IDE shows you the value. It really helps to understand/debug. Also, you can click on a variable, and use the menu Debug, Add Watch. For example, after "Set vsDoc = vsApp.ActiveDocument", if you set a watch on vsDoc, then by clicking on the plus signs, you can see all of the current properties of the document. --Sam
Putting the Open/Close all together, I have: - Sub OpenExisting()
-
Dim vsApp As Visio.Application
-
Dim vsDoc As Visio.Document
-
Set vsApp = CreateObject("Visio.Application")
-
On Error GoTo PressedCancel
-
vsApp.DoCmd (visCmdFileOpen)
-
On Error GoTo 0 ' Resume normal error processing
-
Set vsDoc = vsApp.ActiveDocument
-
MsgBox "Continue Processing..."
-
Dim sNew As String
-
sNew = Split(vsDoc.Name, ".")(0)
-
sNew = sNew & "-" & Format(Now(), "MM_dd_yyyy") & ".vsd"
-
vsApp.ActiveDocument.SaveAsEx vsDoc.Path & sNew, visSaveAsRO
-
vsApp.Quit
-
PressedCancel:
-
vsApp.Quit
-
End Sub
Is that clear or is there something that needs explanation? BTW When you run a macro, you can press the "Step Into" button and step through your code with the F8 key. As you step through it, when you hover the mouse over a property or variable, the IDE shows you the value. It really helps to understand/debug. Also, you can click on a variable, and use the menu Debug, Add Watch. For example, after "Set vsDoc = vsApp.ActiveDocument", if you set a watch on vsDoc, then by clicking on the plus signs, you can see all of the current properties of the document. --Sam
thanks, that help a lot.
You use the Characters object: - Dim s As String, i As Integer
-
s = "Not Fun"
-
Dim c As Characters
-
Set c = ActivePage.Shapes(1).Characters
-
i = InStr(c.Text, s)
-
c.Begin = i - 1
-
c.End = i - 1 + Len(s)
-
c.CharProps(visCharacterSize) = 16
-
c.CharProps(visCharacterStyle) = visBold + visItalic
-
c.CharProps(visCharacterColor) = visRed
In this example, "Not Fun" is your replacement text. It is set to 16 point, bold, italic, & red. HTH --Sam
Sam, do you still remember this code? It's on page 2. Is there anyway to break down the replacement text and set to difference size? Just like in your code, s="Not Fun", how to make "Not" to size 16, and "Fun" to size 10. The condition is the "Not" in one row, and the "Fun" in another row.
Thanks
Sam, do you still remember this code? It's on page 2. Is there anyway to break down the replacement text and set to difference size? Just like in your code, s="Not Fun", how to make "Not" to size 16, and "Fun" to size 10. The condition is the "Not" in one row, and the "Fun" in another row.
Thanks
So, you want the first row of text to be 16 and the second row to be 10 for all of your Visio shapes? In that case, I would just iterate through all of the Visio shapes after you've done the replacement.
So, you want the first row of text to be 16 and the second row to be 10 for all of your Visio shapes? In that case, I would just iterate through all of the Visio shapes after you've done the replacement.
yeah, but only to the replacement text.
yeah, but only to the replacement text.
Well then, I would have a sReplace1 and an sReplace2 or if there are a variable number of replacement rows, have an array of replacement text.
Well then, I would have a sReplace1 and an sReplace2 or if there are a variable number of replacement rows, have an array of replacement text.
but how to break the replacement text to sReplace1, sReplace2?
but how to break the replacement text to sReplace1, sReplace2?
You already have it that way in Excel. When you are getting it from Excel, don't concatinate the replacement rows together.
You already have it that way in Excel. When you are getting it from Excel, don't concatinate the replacement rows together.
I thought about that before, but look at my code, -
'ws1 is sheet 1, ws2 is sheet 2
-
'iRow=ws1.Cells(j, 5).value
-
sReplacement = sReplacement &ws1.Cells(j, 6).Text _
-
& ws2.Cells(iRow, i).Text & " " & ws.Cells(j, 7).Text & Chr(10)
-
how can I separate the row?
i think i can just not use the loop but write it out one row by one row for the replacemet text.
Another question, how to set multiply vsDoc as active document? So i can input text to multiply drawing.
i think i can just not use the loop but write it out one row by one row for the replacemet text.
Another question, how to set multiply vsDoc as active document? So i can input text to multiply drawing.
got the row format slove, but still cannot figure out how to input to multiply file.
got the row format slove, but still cannot figure out how to input to multiply file.
multiply file? :confused:
Go slower and give more details
multiply file? :confused:
Go slower and give more details
In excel have three button, two button open two visio drawing directly, they look like: -
Set vsDoc = vsDocs.Open(C:\folder\file#.vsd)
-
and third button use to input the text to those two drawing, but it only can input text to the last opened drawing, not both. I try use for loop -
for each vsdoc in vsapp.documents
-
...
-
next vsdoc
-
but it still input text to only one drawing.
In excel have three button, two button open two visio drawing directly, they look like: -
Set vsDoc = vsDocs.Open(C:\folder\file#.vsd)
-
and third button use to input the text to those two drawing, but it only can input text to the last opened drawing, not both. I try use for loop -
for each vsdoc in vsapp.documents
-
...
-
next vsdoc
-
but it still input text to only one drawing.
Well, you must have two Visio Applications. In the button code, you need to check the global, vsApp. If vsApp Is Nothing, then you start Visio, otherwise, you just use vsApp. But, make sure that vsApp is only defined in one place: in the Code module (Module1).
Well, you must have two Visio Applications. In the button code, you need to check the global, vsApp. If vsApp Is Nothing, then you start Visio, otherwise, you just use vsApp. But, make sure that vsApp is only defined in one place: in the Code module (Module1).
The two visio application already open before press the input text button. Should I check if vsApp is Nothing in the input text button? but it is already open, it cannot open again.
The two visio application already open before press the input text button. Should I check if vsApp is Nothing in the input text button? but it is already open, it cannot open again.
Never Mind. I don't need to input to multiple application.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Richard Walden |
last post by:
All,
I am trying to figure out how to draw Visio-like 'connector' lines
that would 'lock' to two different images and would resize itself as
the ending images would move. Any thoughts or...
|
by: Stefan Svensson |
last post by:
I posted this request for help in Visio, troubleshooting
newsgroup and Installation newsgroup, about 1,5 months ago
but without result.
"I recently installed Visio .NET Enterprise Architect 2003...
|
by: Eli |
last post by:
I'm developing a Visual Basic .Net app that interacts with
Visio 2002. I have an event handler in VB to handle the
Visio "SelectionChanged" event. This event handler is
called when the event is...
|
by: Ankan |
last post by:
I have installed framework 1.1. and SP 1 on my computer.
I include a textbox to my form but it can only be resized horisontally and
not vertically. What is wrong? (It works fine on other components...
|
by: jessprev |
last post by:
Hello,
I have a database with customer information. I would like to add a
button
that will dynamically open a visio diagram of their network based on
the
customer name.
For example if ABCCo...
|
by: avanti |
last post by:
Hi,
I have a multiline textbox in my application. It starts out as a single
line textbox. I want it to increase in height to accomodate another
line at runtime if the user input exceeds it's...
|
by: Mike Logan |
last post by:
I would like to dynamically create a Visio diagram from .Net. I tried
looking at the Visio SDK, but the samples are extremely convoluted for me to
understand.
Does someone have an example of...
|
by: garyusenet |
last post by:
I have a multiline textbox.
The size of the text box should be 75 characters wide, and 5 lines in
height like this: -
<---75 characters-->
<---75 characters-->
<---75 characters-->
<---75...
|
by: =?Utf-8?B?Q2F0aA==?= |
last post by:
Hi!
I'd like to link a Visio diagram with a Visual Basic application. Is it
possible ?
|
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...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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: 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...
| |