I would like to always export a particular report as a pdf document to the current "desktop" of that specific PC, without hardcoding the "user" of that computer in the vba. My current vba is: - DoCmd.OutputTo acOutputReport, "Drugusage", acFormatPDF, , True
Any suggestions please
I remembered where I had used the DoCmd.OutputTo in one of my databases so I tested my theory on that and what I had in my previous post didn't work. So I tested my other idea and it did work. Here it is: - Dim strUserName As String, strPath As String
-
-
strUserName = Environ("username")
-
strPath = "C:\Users\" & strUserName & "\desktop\Drugusage.pdf"
-
-
DoCmd.OutputTo acOutputReport, "Drugusage", acFormatPDF, strPath, True
I had to manually put in your information so you might check that I have typed everything correctly.
12 14878
I don't know if this works in VBA, but in windows scripting the %username% takes the place of the user name in the file path. It might be something to look into.
Edit: If this is something that will have to work across Win XP & 7, just know that the file path is different for each OS. XP uses Documents and Settings while 7 uses Users. I'm not sure how to tell the database which path to use. I normally make a folder on the C:\ drive and then make a shortcut on the desktop to that folder if I need to. It simplifies the VBA end.
It will be for different windows 7 machines only.
Okay. I don't have a test database to work with, but you could try the following: - DoCmd.OutputTo acOutputReport, "Drugusage", acFormatPDF, "C:\Users\%username%\Desktop\Drugusage.pdf", True
If that doesn't work I have another idea, but lets start with that for now.
--**DOES NOT WORK**-- Moderators can remove post.
I remembered where I had used the DoCmd.OutputTo in one of my databases so I tested my theory on that and what I had in my previous post didn't work. So I tested my other idea and it did work. Here it is: - Dim strUserName As String, strPath As String
-
-
strUserName = Environ("username")
-
strPath = "C:\Users\" & strUserName & "\desktop\Drugusage.pdf"
-
-
DoCmd.OutputTo acOutputReport, "Drugusage", acFormatPDF, strPath, True
I had to manually put in your information so you might check that I have typed everything correctly.
Thx a Seth it works great !!! I have also tried it for a database of mine
Just curious, are you working with Neelsfer on this?
Seth you are a star. It is working as i expected it to work
Not a problem neelsfer. It was actually exciting for me because this is one of just a few times where I have been able to take pieces from other puzzles and put them together and make a whole new picture :) I have used different part of my code in separate databases, but never together so it was nice to see it all come together so nicely.
zmbd 5,501
Expert Mod 4TB
YEA Seth!
It was only a matter of time!
As for the environment variable: "%USERPROFILE%\Desktop"
It has been this since windows97 and continues thru windows7. I have not had a hand's on with windows8. I typically use this to place a document in the users' document folder.
As for a longer term solution (and something I've considered moving to): http://msdn.microsoft.com/en-us/libr...ffice.10).aspx I believe that ADezii will have a better handle on that method.
NeoPa 32,556
Expert Mod 16PB
FYI: CJFer was a temporary account Neels (neelsfer) used when his main one was temporarily unavailable.
NeoPa 32,556
Expert Mod 16PB
It would be harsh to reset the Best Answer, but I would suggest Seth remember Z's solution for future use. It is preferable, and more reliable, as it doesn't presuppose the user's profile is under C:\Users (Which actually reflects a relatively recent change in fact - Windows7 and forward only).
I skimmed the website enough to know that I will have to go back when I have more time, so I have put it in my favorites to make it easier to find and also reference the next time I want to do something like this (which might be soon).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Olya |
last post by:
I'm developing reports with using Crystal Report Viewer
on ASP.NET. After I have report done I try to export it
to .PDF format and get the following error:
"Error in File...
|
by: Majstor |
last post by:
Does anybody know how to export Report in Word, Excel or HTML with
pictures (Access 2000)? I don't use snapshot format.
|
by: Li Pang |
last post by:
Hi,
I built a web form to display a crystal report in web, every thing work
properly. I added then a button to display the report in the embedded adobe
reader by using the below codes:
Dim...
|
by: jpr |
last post by:
Friend, I am using a code to export data from a table to a word
document using bookmarks and have a problem with a date format.
When I export a field that is a mm/dd, in my word doc it shows up...
|
by: Mariana |
last post by:
Hello,
I am exporting reports in pdf format from .net 2005 . The export is working fine; however the user values of stored procedure parameters does not show in the report. What do I need to do in...
|
by: Joe Schmo |
last post by:
Is there any way to export an Access Report, including the format, into a
Word document - other than printing to a PDF.
|
by: 1q2w3e4r5t6y7u8i |
last post by:
Hi,
I am printing an invoice through the following code:
dim cr as new crystalreport1
cr.PrintToPrinter(1, False, 1, 1)
the problem is that the complete paper cames out. I want to print...
|
by: muddasirmunir |
last post by:
is there any way or third party utility which can export our
data report to pdf format i am usinig vb6
i know crystal report can do that but i had a project with data report
is there any way to...
|
by: ttfitz |
last post by:
I have an application developed in Access 2000, to be distributed as
an MDE. For those folks without Access, they install the free Access
2007 runtime. For the most part, this seems to be working...
|
by: ghiey |
last post by:
hi to all,
i have searched for a solution regarding exporting access 2007 reports to excel file.
i have converted to access 2007 my database from access 2003.
i guess microsoft omitted the ease...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
| |