?
Solved

create file in memory

Posted on 2005-04-01
12
Medium Priority
?
583 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
  • 3
  • 2
  • 2
  • +2
9 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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 Month12 days, 19 hours left to enroll

579 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