Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Command button that prints multiple hyperlinks 1

Status
Not open for further replies.

KochChic

Technical User
Nov 17, 2008
10
US
I am not familiar with coding but it's time I become...I have a list of hyperlinks (an orientation package, that consists of web pages and MS documents located on a share drive) and would like a button on my form (Access 2003) that will not display these links but just print them out. I have tried all that I know and all I get is a copy of my form...please help...any and all advice is GREATLY appriciated!!!
Thanks in advance,
KochChic
 
Not sure what the problem is. Do you have a field in a table that contains hyperlinks? Just create a report with that field , then on a command button's OnClick event put
DoCmd.OpenReport "ReportName"

Or you don't know how to put code in VBA?
Maybe you could explain clearer.
 
Fneily...Thanks so much for helping. I created a report with the hyperlink fields and created a command button to open report and print...I get a copy of the report when utilizing the button. I need the actual web pages and word document to print...and no I don't know much about putting code into VBA...just know it works well when one knows exactly what they are doing! :)
Thanks again for you time and help...it is GREATLY appriciated!
KochChic
 
If you look at:

you'll see a more advanced Followhyperlink function. It'll show you how to use it to open a web page or word doc from your form. Do you want the user to open the web page and word doc first, then print as usual? Or do you want to loop through hyperlinks and print them off in mass? I wouldn't do it in mass.
 
Our problem is that for every job plan (almost 200 job plans) there is at least 10 sets of print outs and they are stored in multiple locations. As of now it takes great effort to locate the correct documentation and ensure all are printed. My boss's computer skills aren't great and he wanted to pull up a "Job Plan" and click a button for all needed documentation to print out...so I guess printing them off in mass is what he's asking for. I figured that would be the easiest way to go...but always open to a better/easier route. I'm going to check out the link you provided for me and pray that helps! Thank you so much!
KochChic
 
Doesn't sound to well organized. Since they are not now stored in one location, you can't guarantee they'll be stored in the same place in the future.
Why don't you have someone just physically move the appropriate set of print outs for a job to a central location? The time spent will same a ton of future headaches. I had the same problem at AT&T during the split up. We had to send new code to 7 separate phone companies. At first, no one knew who had what version or update. So we created the Central Management Control Center. All problems, codes, fixes went through a central place. Made life easier.
Even if you get your way working, it could fail next week if someone decides, out of the blue, to create a new folder on another drive .

Right now, you'll have a table with Plans (tblJobPlans) that has a one-to-many relationship with the sets (tblSets) but the sets are all over the place.

Also, you mentioned web pages. Web pages are usually out of sync timewise. Why don't you just focus on documents?
 
It's crazy...they have 3 different internet based drives (I guess is what you call them) and the shared drive for the facility that I actually work in. All of these drives contain documents that I need. I've been telling them that one is good...not 4 different storage drives. They can't hear...this being the reason I'm in this situation anyway.:)
The webpages I refered to are the documents on the internet based drives (the only way I can get to them is to navigate through the web page we call MOE). I would just save them to the local shared drive but they update so often I'm afraid we would still be defeating the purpose.
 
Aren't the webpage documents in HTML format? So you'd also need to strip that out.

I'm trying to think of an easy way to do this. Maybe create a folder for each job plan. Set up a macro you can run everyday to copy the appropriate sets into the corresponding folder. Then in an Access table, you could have a list of job plan names which you can create a combobox from. When the user selects a job plan, then write some code for a command button to print off the contents of that folder.

The reason being is that there's code floating around here that all ready loops through a directory.

Maybe someone else has an idea.
 
That sounds like it would probably work...how exactly would I utilize the macro to retrive the documents daily?
 
You could create a little form with a command button. Then on the OnClick event of the button, put:

Sub Copy_Files()
FileCopy "C:\Users\SourceFolder\Test.xls", "C:\Users\DestFolder\Test.xls"
Next FileCopy
Etc.
End Sub

So the command buttons name above is Copy_files. The Filecopy function is all on one line. So have several lines copying the files to a destination folder.
For FileCopy you just put in the path of the document and then point to a destination folder.
So you'd have 200 new folders(one for each job plan). A little work but then everything would be in one place. A job that we both agree should have been none originally.
 
OK...that's my starting point! I'm going to try it and see what happens with the update folder command...I will let you know...thank you!
 
I created a sample command button with the code you provided and tweeked it with my document paths. I am getting an "Ambiguous Name Dectected: Copy_Files" error?!?!?!?!?
 
Sorry, can't read minds. You didn't post your code for me to see. Check all your typing.

 
I figured out that I had "Sub" too many times. Now I'm getting a Complie Error: Expected End Sub, and it highlights the Private Sub Command2_Click()...here's the code I'm using...

Private Sub Command2_Click()
Sub Copy_Files()
FileCopy "S:\2008 MSDS (Updated)\0010 - Ammonia, Anhydrous.pdf", "S:\Jessica's Database\Linked Files\Job Plan-YARD\0010 - Ammonia, Anhydrous.pdf"
Next FileCopy
FileCopy "S:\2008 MSDS (Updated)\0080 - Chlorine.pdf", "S:\Jessica's Database\Linked Files\Job Plan-YARD\0080 - Chlorine.pdf"
Next FileCopy
FileCopy "S:\2008 MSDS (Updated)\0452 - 2, 4-D Amine 4.pdf", "S:\Jessica's Database\Linked Files\Job Plan-YARD\0452 - 2, 4-D Amine 4.pdf"
Next FileCopy
FileCopy "S:\2008 MSDS (Updated)\0458 - Diuron 4L.pdf", "S:\Jessica's Database\Linked Files\Job Plan-YARD\0458 - Diuron 4L.pdf"
Next FileCopy
FileCopy "S:\Terminal Operations\Sterlinton JSAsNew Folder\EQUIP - GENERAL MAINTENANCE\JSA 107 SPRAY WEEDS.xls", "S:\Jessica's Database\Linked Files\Job Plan-YARD\JSA 107 SPRAY WEEDS.xls"
Next FileCopy
FileCopy "S:\Terminal Operations\Sterlinton JSAsNew Folder\EQUIP - GENERAL MAINTENANCE\JSA 116 MOW GRASS.xls", "S:\Jessica's Database\Linked Files\Job Plan-YARD\JSA 116 MOW GRASS.xls"



End Sub

 
Private Sub Command2_Click()
Sub Copy_Files()

Did you type Sub Copy_Files()?
You don't need to type Sub or END SUB. VBA does that automatically for you.

Delete the Sub Copy_file().

If you look at your property sheet of the command button, click the ALL tab. You'll see the option Name. This should say Command2. That's the default name of the command button. For now, don't change it.

You should only see pairs:
Sub
End Sub

If
End If

etc.
 
OK! I have edited to only update a single document...it works!!!
Private Sub Command3_Click()

FileCopy "S:\Terminal Operations\Sterlinton JSAsNew Folder\EQUIP - GENERAL MAINTENANCE\JSA 107 SPRAY WEEDS.xls", "S:\Jessica's Database\Linked Files\Job Plan-YARD\JSA 107 SPRAY WEEDS.xls"

End Sub


I added Next FileCopy and FileCopy 2nd set of paths:

Private Sub Command3_Click()

FileCopy "S:\Terminal Operations\Sterlinton JSAsNew Folder\EQUIP - GENERAL MAINTENANCE\JSA 107 SPRAY WEEDS.xls", "S:\Jessica's Database\Linked Files\Job Plan-YARD\JSA 107 SPRAY WEEDS.xls"
Next FileCopy
FileCopy "S:\Terminal Operations\Sterlinton JSAsNew Folder\EQUIP - GENERAL MAINTENANCE\JSA 116 MOW GRASS.xls", "S:\Jessica's Database\Linked Files\Job Plan-YARD\JSA 116 MOW GRASS.xls"
End Sub

I get Complie Error: Argument Not Optional and the FileCopy beside Next is highlighted...
 
Delete "Next FileCopy". That was pseudo code for you to follow. It's just a bunch of FileCopy's.
 
OH!!! That made me feel really smart! :)
So now I have a command button that will update document to "my organized folder of folders"! You mentioned earlier that I could write a code that will print the contents of a folder? Please elaborate...my smarts are showing once again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top