?
Solved

create file in memory

Posted on 2005-04-01
12
Medium Priority
?
562 Views
Last Modified: 2008-01-09
Hi everyone,

I have a VBA problem. I am using VBA in Visio. What I want to do is create a text file entirely in memory and use it in methods that expect a file name string. Basically, I want all the contents to be saved in memory and not on the client's disk. Is there any way to create such files in VBA? No file in HD should be created.

Cheers!
0
Comment
Question by:xargon_123
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +2
12 Comments
 
LVL 1

Expert Comment

by:michaeldade
ID: 13679295
memory mapped files may be the way to go
0
 

Author Comment

by:xargon_123
ID: 13679300
Can you post some example on how I can do this in VBA?

Cheers!
0
 
LVL 8

Expert Comment

by:anthonywjones66
ID: 13679326
What is your reason for not wanting to create a temporary file?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:xargon_123
ID: 13679350
Well, the user may or may not have the permission to create a file on the HD. Plus, my requirement states that no physical file should be used and I want to exhaust that possibility before deviating.

Cheers!
0
 
LVL 16

Accepted Solution

by:
jimbobmcgee earned 2000 total points
ID: 13679714
Please clarify:

   -  How are you opening your 'file'?  
   -  You want to use standard ReadLine/WriteLine functionality?  
   -  What specifies the filename?
   -  What is different from using myVariable = myVariable + "new text to add"

Give an example of a file-based approach that you'd implement if you could and we'll see what we can do...

J.
0
 

Author Comment

by:xargon_123
ID: 13680672
Well, the thing is this:

I have a Visio document and I am trying to find a way to get the XML representation of the document from the VBA module inside.

There is no method in Visio to get the complete document XML (you can only access the SolutionXML tag). So, basically you have to save the file as an XML file on the disk and read it again. However, I do not want to create a physical file on the HD and I was wondering if there is a way to create a 'file' in the client's memory and save the document to the memory file and basically read that memory block again into my string variable.

Cheers!
0
 
LVL 16

Expert Comment

by:jimbobmcgee
ID: 13697339
Basically, you need Visio to export XML as a stream, not a file.  I don't think Visio has a procedure to do this.  So unless you want to write it yourself, looping through each of the shapes and creating the valid XML code, I'd look at alternatives, such as running the app under a particular user account or writing data to the Documents and Settings/Application Data/All Users folder.

J.
0
 
LVL 1

Expert Comment

by:syedrizwanm
ID: 13697993
May I ask a humble question, why dont you want to use a variable to retain the XML for the lifetime of the program? writing data to a memory mapped file is equivalent to keeping it in a variable.

Do let me know ur answer.
0
 
LVL 1

Expert Comment

by:syedrizwanm
ID: 13698049
Also you can use XMLDOM to manipulate XML string in memory
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month14 days, 12 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question