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

Can VBA Talk to Python

2
Ok here is my goal that I am trying to accomplish.
First of all before I start mentioning my problem.
I am a beginner in programming have been taking classes from learnpythonthehardway.com and codeacademy.com roughly 6 months.
My goal is to be able to get a data which contains lattitude and longitude in other words x, and Y. I want to send that data to python which will open my program called Arc Gis or Arc Map version 10.0 which highly depends on python scripting for automation. When I take that value my x and y I want python to use the arcpy library to search it on the map and plotting it. Is like puting the x and y on google maps and searching.


my code for python so far I am telling it to open the arcMap.

Example code that I have so far.
Expand|Select|Wrap|Line Numbers
  1. import subprocess
  2. Choose_Program = raw_input("What Program you want to open").lower()
  3. choosen = Choose_Program
  4.  
  5. if choosen == 'arcmap':
  6.     subprocess.Popen([r"C:\Program Files (x86)\ArcGIS\Desktop10.0\Bin\ArcMap.exe", r"\\911SERVER\911_dept\10_TRAINING\GIS\hector_training.mxd"])
  7.  
  8. else:
  9.     print "Not Valid Program Please Choose Another Program"
Apr 10 '13 #1
7 6718
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

You haven't mentioned how VBA fits into all of this. But as far as passing information along, I don't know if you can but you can always work around it by writing out the information to a file and then reading it in from python.

On a side note, what is the purpose of line 3? Why make a copy of the value when you can use the original value itself?
Apr 10 '13 #2
NeoPa
32,556 Expert Mod 16PB
Two programs running at the same time (The language of each is almost completely irrelevant) cannot communicate directly with each other unless they have been specifically designed and coded to do so.

Inter Process Communication (You may read about IPCs when studying and this is what they are referring to.) is a whole subject in itself, and can be done using O/S provided calls. It can also be done, as Rabbit indicates, by storing and loading information from files.

Natively, though, VBA programs at least have no built-in IPC capabilities.
Apr 10 '13 #3
noe956
2
Rabbit and NeoPa.
Let me explain more. I have a microsoft access database that our employees use every day. The customer calls in and we input the information into the database. When my co-worker inputs information into a specific form there are some data I want to push out in other words extract out for it can plot on the other software called ArcMap that uses python to automated process. I want the vba to get the value of the form pass it to python and python reads the value and plots it in the Arc Map by using gps coordinates. First, of all I dont know what to write on vba to make it work to send the data over to python. I know you guys suggest to write the information into a file I don't know any solutions so that's why I am asking here for help. Lines two and three you can just disregard that coding because it was to see if it would actually work and open that file which it did.
Apr 11 '13 #4
Rabbit
12,516 Expert Mod 8TB
Well, if you're invoking a command in VBA to call python to run a python script, I would not be surprised if the command also allowed you to pass parameters to the script you're calling.

But to be sure, we would first need to know how you're invoking the script. And second, you would need to read the python documentation to see if you can pass parameters on the command line and how to do so.
Apr 11 '13 #5
NeoPa
32,556 Expert Mod 16PB
That may be more explanation, but I don't see that it helps any. The answers already provided are a good fit for the question posed. We don't sit here and simply do code for you. Even if we were inclined to the site rules prohibit it.

If that's what you're after, apart from not getting it here, you will need to provide more appropriate detail as to what you're working with. If you manage to find anyone willing to do that for you, on a site where that is even allowed, they won't be able to help you much unless you can provide more helpful details than are here.

Good luck.
Apr 11 '13 #6
ADezii
8,834 Expert 8TB
@Rabbit
Wouldn't the question be: Does Arc Map accept Command Line Arguments, and can Python read those Arguments? It could also be that I have things backwards! (LOL).
Apr 14 '13 #7
Rabbit
12,516 Expert Mod 8TB
Well, it sounds to me like they have a python script that calls arc map. And they want to call that script and pass it some data from the database.
Apr 14 '13 #8

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

Similar topics

14
by: David MacQuigg | last post by:
I am starting a new thread so we can avoid some of the non-productive argument following my earlier post "What is good about Prothon". At Mr. Hahn's request, I will avoid using the name "Prothon"...
7
by: Michele Simionato | last post by:
So far, I have not installed Prothon, nor I have experience with Io, Self or other prototype-based languages. Still, from the discussion on the mailing list, I have got the strong impression that...
0
by: pyuk2005 | last post by:
The UK Python Conference for 2005 will take place at the Randolph Hotel, Oxford on 20-23 April 2005. This is the FINAL CALL for talks. The original deadline of 26th December has been extended...
6
by: Franz Mueller | last post by:
Hi, which of the following books would you recommend: "Dive into Python" or "Beginning Python: From Novice to Professional"? I'm an experienced C++-programmer who wants to take a look at...
0
by: Brian Quinlan | last post by:
What's New? =========== The deadline for submitting a talk or tutorial for the Vancouver Python Workshop is fast approaching. Talks will be accepted until Friday June 16th. To submit a talk,...
0
by: Brian Quinlan | last post by:
What's New? =========== This is your last change to submit a talk for the Vancouver Python Workshop. Talks will be accepted until Friday June 16th. This is a great opportunity for you to...
0
by: Jeff Rush | last post by:
Eggs are important to Python and will become more so over the next few years, if understood and embraced by the community. They are a key competitive feature - I've been asked so many times what...
4
by: meyousikmann | last post by:
I am working on an implementation of the Longest Common Subsequence problem (as I understand it, this problem can be used in spell checking type activities) and have used this site to understand...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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 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.