I created a button in excel sheet, and that button need to browse and open a visio drawing. I try two ways to do it, but either way work. can anyone help?
First way:
Private Sub CommandButton1_Click()
Dim objVisio As Visio.Application
Set objVisio = New Visio.Application
objVisio.Visible = True
Dim vFile As Variant
vFile = objVisio.Documents.Open("All Visio Files (*.vs*; *.v?x)")
If vFile <> False Then
Dim vsobj As Visio.Document
Set vsobj = objVisio.Documents.Add(vFile)
End If
End Sub
Second way:
Private Sub button1_click()
Dim objVisio As Visio.Application
Set objVisio = New Visio.Application
objVisio.Visible = True
Dim uiObj As Visio.UIObject
Set uiObj = objVisio.BuiltInToolbars(0)
End Sub
14 5887
I mean both way not work.
I mean both way not work.
someone help
I created a button in excel sheet, and that button need to browse and open a visio drawing. I try two ways to do it, but either way work. can anyone help?
Your first way looks almost correct, but you want to use Excel's Application.GetOpenFileName instead of objVisio.Documents.Open. I don't have Visio here to test it. Reply back if you still have problems: I can test it at home tonight. --Sam
Your first way looks almost correct, but you want to use Excel's Application.GetOpenFileName instead of objVisio.Documents.Open. I don't have Visio here to test it. Reply back if you still have problems: I can test it at home tonight. --Sam
I try GetOpenFileName before, GetOpenFileName not support visio.
I try GetOpenFileName before, GetOpenFileName not support visio.
GetOpenFileName is an Excel interface to get a FileName. If you are running Excel, then Application.GetOpenFileName will pop-up a dialog that looks like a File Open; however, it does not open anything. It returns a variant that contains the filename that the user selected or False if the user pressed Cancel. Notice how I used it in an eariler response to you, http://www.thescripts.com/forum/post2432069-18.html.
You, then, use this variant in the Visio.Documents.Add as the chart to open.
GetOpenFileName is an Excel interface to get a FileName. If you are running Excel, then Application.GetOpenFileName will pop-up a dialog that looks like a File Open; however, it does not open anything. It returns a variant that contains the filename that the user selected or False if the user pressed Cancel. Notice how I used it in an eariler response to you, http://www.thescripts.com/forum/post2432069-18.html.
You, then, use this variant in the Visio.Documents.Add as the chart to open.
I got what you mean, but it just not working:
Private Sub CommandButton1_Click()
Dim objVisio As Visio.Application
Set objVisio = New Visio.Application
objVisio.Visible = True
Dim vFile As Variant
vFile = objVisio.GetOpenFileName("All Visio Files (*.vs*; *.v?x)")
If vFile <> False Then
Dim vsobj As Visio.Document
Set vsobj = objVisio.Documents.Add(vFile)
End If
End Sub
GetOpenFileName is an EXCEL object. Use Application.GetOpenFileName(...)
GetOpenFileName is an EXCEL object. Use Application.GetOpenFileName(...)
I tried:
vFile = objVisio.Application.GetOpenFileName("All Visio Files (*.vs*; *.v?x)")
vFile = objVisio.visio.GetOpenFileName("All Visio Files (*.vs*; *.v?x)")
vFile = Application.GetOpenFileName("All Visio Files (*.vs*; *.v?x)")
vFile = Visio.GetOpenFileName("All Visio Files (*.vs*; *.v?x)")
They all said Object don't support this property or method.
Third one is close, but should be - vFile = Application.GetOpenFilename("All Visio Files (*.vs*;*.v?x), *.vs*;*.v?x")
Third one is close, but should be - vFile = Application.GetOpenFilename("All Visio Files (*.vs*;*.v?x), *.vs*;*.v?x")
Yeah, it do work. thanks
Fantastic! (¬_¬)/¯
Sam,
Hope you see this message.
after i open the visio drawing, i need to input text to it. It work when:
Set vsPage=vsDoc.Pages(1)
but what i want is input text to the active page, so i try:
Set vsPage=vsDoc.activepage
Set vsPage=vsApp.vsDoc.activepage
Set vsPage=vsApp.activepage
Set vsPage=vsApp.activewindow.activepage
However, they all are not working, do u know what is wrong?
Thanks
Sam,
Hope you see this message.
after i open the visio drawing, i need to input text to it. It work when:
Set vsPage=vsDoc.Pages(1)
but what i want is input text to the active page, so i try:
Set vsPage=vsDoc.activepage
Set vsPage=vsApp.vsDoc.activepage
Set vsPage=vsApp.activepage
Set vsPage=vsApp.activewindow.activepage
However, they all are not working, do u know what is wrong?
Thanks
Sorry, no Visio here, I'll try tonight. The only thing that I have used is what worked for you, Set vsPage=vsDoc.Pages(1). Maybe when you open the document, there is no active page, but that seems strange. From Help: "The ActivePage property returns a Page object only when the active window displays a drawing page; otherwise, it returns Nothing. To verify that a page is active, use the Is operator to compare the ActivePage property with Nothing."
So, you probably want (not tested) - If vsApp.ActivePage Is Nothing Then
-
Set vsPage = vsDoc.Pages(1)
-
Else
-
Set vsPage = vsApp.ActivePage
-
End If
Here's some other code that worked for me that may help you. - Dim vsApp As Visio.Application
-
Dim vsDoc As Visio.Document
-
Dim vsPage As Visio.Page
-
Dim vsWindow As Visio.Window
-
Set vsApp = CreateObject("Visio.Application")
-
Set vsDoc = vsApp.Documents.Add("basic shapes.vss")
-
Set vsPage = vsDoc.Pages(1)
-
Set vsWindow = vsPage.OpenDrawWindow
-
vsApp.Windows.Arrange visArrangeTileVertical
-
vsWindow.Zoom = 1#
Sorry, no Visio here, I'll try tonight. The only thing that I have used is what worked for you, Set vsPage=vsDoc.Pages(1). Maybe when you open the document, there is no active page, but that seems strange. From Help: "The ActivePage property returns a Page object only when the active window displays a drawing page; otherwise, it returns Nothing. To verify that a page is active, use the Is operator to compare the ActivePage property with Nothing."
So, you probably want (not tested) - If vsApp.ActivePage Is Nothing Then
-
Set vsPage = vsDoc.Pages(1)
-
Else
-
Set vsPage = vsApp.ActivePage
-
End If
Here's some other code that worked for me that may help you. - Dim vsApp As Visio.Application
-
Dim vsDoc As Visio.Document
-
Dim vsPage As Visio.Page
-
Dim vsWindow As Visio.Window
-
Set vsApp = CreateObject("Visio.Application")
-
Set vsDoc = vsApp.Documents.Add("basic shapes.vss")
-
Set vsPage = vsDoc.Pages(1)
-
Set vsWindow = vsPage.OpenDrawWindow
-
vsApp.Windows.Arrange visArrangeTileVertical
-
vsWindow.Zoom = 1#
Yeah, it is working now. thanks
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Hai Ly Hoang |
last post by:
Hi,
I want to open a visio drawing file (.vsd) from hardisk and get the list of
all shape in that file ? How to do that ?
Thank your very much !
Hai
|
by: marc |
last post by:
Hi,
I make a web application than use visio, excel and word
to create files. In my web.config, I've the next line :
<identity impersonate="true" userName="user1"
password="pwd1" />
user1 is...
|
by: jes |
last post by:
hi,
i have an open & delete btn. onclick of open as visio drawing opens in visio
& onclick of delete the drawing gets deleted from the filesystem. The problem
is i am unable to perform these...
|
by: Ronchese |
last post by:
Hello.
Is there any way to integrate the Microsoft Visio and Microsoft Visual
Studio 2005 Professional? I read that this integration is supplied by VS
Team System Architect edition, but I would...
|
by: joemo2003 |
last post by:
In excel use "Application.Dialogs(xldialogopen).Show" to open a opendialogbox. Anybody know what is the name for the open dialogbox in Visio?
thanks
|
by: joemo2003 |
last post by:
I try to compare the text in excel and visio, if the text match, then replace that visio text with a range of excel text. Do anybody have any experiment with that? any ideal will be a big help.
...
|
by: poonamsharma |
last post by:
Hi,
I want to open a already exist visio drawing through VB language. I create a form inside Microsoft Access and put a command button over it .I want that while clicking on it ,it opens the visio...
|
by: Aprile |
last post by:
Hello, everyone. My sister sent me a Visio file but I don't have MS Visio. Now, I'm wondering if OpenOffice Draw can open it. From what I know, that's not the case last year. I'm not sure if there...
|
by: =?Utf-8?B?VGluX0xlVVNB?= |
last post by:
Hi all, I would like to use C# to read a designed Visio file and out out to
eith text file or excel file so that I can generate the codes in VB.Net or C#.
Any lead greatly appreciated.
--
Tin...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
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...
|
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...
|
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...
|
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...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
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...
| |