473,326 Members | 2,104 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,326 software developers and data experts.

open visio in Excel

142 100+
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
Mar 16 '07 #1
14 5887
joemo2003
142 100+
I mean both way not work.
Mar 17 '07 #2
joemo2003
142 100+
I mean both way not work.
someone help
Mar 19 '07 #3
SammyB
807 Expert 512MB
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
Mar 19 '07 #4
joemo2003
142 100+
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.
Mar 19 '07 #5
SammyB
807 Expert 512MB
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.
Mar 19 '07 #6
joemo2003
142 100+
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
Mar 19 '07 #7
SammyB
807 Expert 512MB
GetOpenFileName is an EXCEL object. Use Application.GetOpenFileName(...)
Mar 19 '07 #8
joemo2003
142 100+
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.
Mar 19 '07 #9
SammyB
807 Expert 512MB
Third one is close, but should be
Expand|Select|Wrap|Line Numbers
  1. vFile = Application.GetOpenFilename("All Visio Files (*.vs*;*.v?x), *.vs*;*.v?x")
Mar 19 '07 #10
joemo2003
142 100+
Third one is close, but should be
Expand|Select|Wrap|Line Numbers
  1. vFile = Application.GetOpenFilename("All Visio Files (*.vs*;*.v?x), *.vs*;*.v?x")
Yeah, it do work. thanks
Mar 19 '07 #11
SammyB
807 Expert 512MB
Fantastic! (¬_¬)/¯
Mar 19 '07 #12
joemo2003
142 100+
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
Mar 20 '07 #13
SammyB
807 Expert 512MB
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)
Expand|Select|Wrap|Line Numbers
  1.     If vsApp.ActivePage Is Nothing Then
  2.         Set vsPage = vsDoc.Pages(1)
  3.     Else
  4.         Set vsPage = vsApp.ActivePage
  5.     End If
Here's some other code that worked for me that may help you.
Expand|Select|Wrap|Line Numbers
  1.     Dim vsApp As Visio.Application
  2.     Dim vsDoc As Visio.Document
  3.     Dim vsPage As Visio.Page
  4.     Dim vsWindow As Visio.Window
  5.     Set vsApp = CreateObject("Visio.Application")
  6.     Set vsDoc = vsApp.Documents.Add("basic shapes.vss")
  7.     Set vsPage = vsDoc.Pages(1)
  8.     Set vsWindow = vsPage.OpenDrawWindow
  9.     vsApp.Windows.Arrange visArrangeTileVertical
  10.     vsWindow.Zoom = 1#
Mar 20 '07 #14
joemo2003
142 100+
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)
Expand|Select|Wrap|Line Numbers
  1.     If vsApp.ActivePage Is Nothing Then
  2.         Set vsPage = vsDoc.Pages(1)
  3.     Else
  4.         Set vsPage = vsApp.ActivePage
  5.     End If
Here's some other code that worked for me that may help you.
Expand|Select|Wrap|Line Numbers
  1.     Dim vsApp As Visio.Application
  2.     Dim vsDoc As Visio.Document
  3.     Dim vsPage As Visio.Page
  4.     Dim vsWindow As Visio.Window
  5.     Set vsApp = CreateObject("Visio.Application")
  6.     Set vsDoc = vsApp.Documents.Add("basic shapes.vss")
  7.     Set vsPage = vsDoc.Pages(1)
  8.     Set vsWindow = vsPage.OpenDrawWindow
  9.     vsApp.Windows.Arrange visArrangeTileVertical
  10.     vsWindow.Zoom = 1#

Yeah, it is working now. thanks
Mar 20 '07 #15

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

Similar topics

2
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
0
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...
4
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...
1
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...
5
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
33
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. ...
2
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...
2
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...
0
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...
0
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...
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: 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)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
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....
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.