Windows variables in macros

  • Thread starter Thread starter Kathy Webster
  • Start date Start date
If it didn't pop up any error messages when you tried to compile, then the
option will be greyed out until you make a change and the application needs
to be recompiled. In any case, that implies that you copied the code
correctly.

What happens if you go to the Immediate window (Ctrl-G), type

?fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

and hit Enter? Do you get the correct path? If you do, then it would appear
you've set the field up incorrectly on your switchboard. Where exactly did
you put =fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA) for that field? (It
needs to be in the ControlSource property)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Kathy Webster said:
I did it, it seemed to work. Now the option is greyed out.

Douglas J. Steele said:
What happens if you try to compile your application? (While you're in the
VB Editor, it's the first option on the Debug menu)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Kathy Webster said:
Hi Doug. Glad you are back.
I named it UserPaths.
After pasting the code in, it seems to have added "Option Compare
Database" above the first commented line of the code.

What did you name the module, Kathy?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hmm, I'm trying to display the user apps folder name in a field on the
switchboard form, just to see if it is even receiving the information.
The name of the field on the switchboard is [UserPathLocation]. I
already tried the equal sign, with the same #Name? result.


On Mon, 16 Oct 2006 17:38:33 GMT, "Kathy Webster"

-I made a field in the switchboard and set its control source to
fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

-The field is displaying #Name?

Use

=fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

This assumes that CSIDL_LOCAL_APPDATA is the name of a control on the
switchboard form which contains the information that
fGetSpecialFolderLocation needs.

John W. Vinson[MVP]
 
With the switchboard on screen, and my cursor blinking in the field, I hit
Ctrl+G, get the immediate window, and paste your string and press enter. It
displays the correct path (so far this is very exciting!)

I double checked, and repasted your value below...it is the ControlSource
property of my txtBox called [Text44] in the switchboard.
But it is still displaying #Name?.

Hey-ulp! (distress call from the southern belle semi-programmer)


Douglas J. Steele said:
If it didn't pop up any error messages when you tried to compile, then the
option will be greyed out until you make a change and the application
needs to be recompiled. In any case, that implies that you copied the code
correctly.

What happens if you go to the Immediate window (Ctrl-G), type

?fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

and hit Enter? Do you get the correct path? If you do, then it would
appear you've set the field up incorrectly on your switchboard. Where
exactly did you put =fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA) for
that field? (It needs to be in the ControlSource property)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Kathy Webster said:
I did it, it seemed to work. Now the option is greyed out.

Douglas J. Steele said:
What happens if you try to compile your application? (While you're in
the VB Editor, it's the first option on the Debug menu)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hi Doug. Glad you are back.
I named it UserPaths.
After pasting the code in, it seems to have added "Option Compare
Database" above the first commented line of the code.

message What did you name the module, Kathy?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hmm, I'm trying to display the user apps folder name in a field on
the switchboard form, just to see if it is even receiving the
information. The name of the field on the switchboard is
[UserPathLocation]. I already tried the equal sign, with the same
#Name? result.


On Mon, 16 Oct 2006 17:38:33 GMT, "Kathy Webster"

-I made a field in the switchboard and set its control source to
fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

-The field is displaying #Name?

Use

=fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

This assumes that CSIDL_LOCAL_APPDATA is the name of a control on
the
switchboard form which contains the information that
fGetSpecialFolderLocation needs.

John W. Vinson[MVP]
 
Sorry, but I'm running out of ideas!

Just for kicks, try adding a new text box to your form, and setting its
ControlSource property to =fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)
(complete with equal sign)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Kathy Webster said:
With the switchboard on screen, and my cursor blinking in the field, I hit
Ctrl+G, get the immediate window, and paste your string and press enter.
It displays the correct path (so far this is very exciting!)

I double checked, and repasted your value below...it is the ControlSource
property of my txtBox called [Text44] in the switchboard.
But it is still displaying #Name?.

Hey-ulp! (distress call from the southern belle semi-programmer)


Douglas J. Steele said:
If it didn't pop up any error messages when you tried to compile, then
the option will be greyed out until you make a change and the application
needs to be recompiled. In any case, that implies that you copied the
code correctly.

What happens if you go to the Immediate window (Ctrl-G), type

?fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

and hit Enter? Do you get the correct path? If you do, then it would
appear you've set the field up incorrectly on your switchboard. Where
exactly did you put =fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA) for
that field? (It needs to be in the ControlSource property)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Kathy Webster said:
I did it, it seemed to work. Now the option is greyed out.

What happens if you try to compile your application? (While you're in
the VB Editor, it's the first option on the Debug menu)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hi Doug. Glad you are back.
I named it UserPaths.
After pasting the code in, it seems to have added "Option Compare
Database" above the first commented line of the code.

message What did you name the module, Kathy?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hmm, I'm trying to display the user apps folder name in a field on
the switchboard form, just to see if it is even receiving the
information. The name of the field on the switchboard is
[UserPathLocation]. I already tried the equal sign, with the same
#Name? result.


On Mon, 16 Oct 2006 17:38:33 GMT, "Kathy Webster"

-I made a field in the switchboard and set its control source to
fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

-The field is displaying #Name?

Use

=fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

This assumes that CSIDL_LOCAL_APPDATA is the name of a control on
the
switchboard form which contains the information that
fGetSpecialFolderLocation needs.

John W. Vinson[MVP]
 
No go...so I put it in the form's OnLoad event, which is one of your
original suggestions, and it works like a champ. Thank you for sticking with
me on this! You're a doll!

Douglas J. Steele said:
Sorry, but I'm running out of ideas!

Just for kicks, try adding a new text box to your form, and setting its
ControlSource property to =fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)
(complete with equal sign)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Kathy Webster said:
With the switchboard on screen, and my cursor blinking in the field, I
hit Ctrl+G, get the immediate window, and paste your string and press
enter. It displays the correct path (so far this is very exciting!)

I double checked, and repasted your value below...it is the ControlSource
property of my txtBox called [Text44] in the switchboard.
But it is still displaying #Name?.

Hey-ulp! (distress call from the southern belle semi-programmer)


Douglas J. Steele said:
If it didn't pop up any error messages when you tried to compile, then
the option will be greyed out until you make a change and the
application needs to be recompiled. In any case, that implies that you
copied the code correctly.

What happens if you go to the Immediate window (Ctrl-G), type

?fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

and hit Enter? Do you get the correct path? If you do, then it would
appear you've set the field up incorrectly on your switchboard. Where
exactly did you put =fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA) for
that field? (It needs to be in the ControlSource property)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


I did it, it seemed to work. Now the option is greyed out.

message What happens if you try to compile your application? (While you're in
the VB Editor, it's the first option on the Debug menu)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hi Doug. Glad you are back.
I named it UserPaths.
After pasting the code in, it seems to have added "Option Compare
Database" above the first commented line of the code.

message What did you name the module, Kathy?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hmm, I'm trying to display the user apps folder name in a field on
the switchboard form, just to see if it is even receiving the
information. The name of the field on the switchboard is
[UserPathLocation]. I already tried the equal sign, with the same
#Name? result.


On Mon, 16 Oct 2006 17:38:33 GMT, "Kathy Webster"

-I made a field in the switchboard and set its control source to
fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

-The field is displaying #Name?

Use

=fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

This assumes that CSIDL_LOCAL_APPDATA is the name of a control on
the
switchboard form which contains the information that
fGetSpecialFolderLocation needs.

John W. Vinson[MVP]
 
One last thing...
I know this isn't officially in your realm, but since you've gotten me this
far...

How do I pass that information to Word?
Because after MSAccess saves its query result to the user's appsdata folder
as "AccessData.txt", MSAccess stores a form file in the same folder called
"mergeform.doc". Word then takes those 2 files and merges them. The data
source of "mergeform.doc" is "AccessData.txt".

The prior folder where all this was stored was c:\msAccessApp.
So my Word macro currently reads:

Documents.Open FileName:="C:\msAccessApp\mergeform.doc",
ConfirmConversions:= _
False, ReadOnly:=False, AddToRecentFiles:=False,
PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.Execute

....and the data source for mergform.doc was c:\msAccessApp\accessdata.txt

Again, my eternal thanks.

Kathy Webster said:
No go...so I put it in the form's OnLoad event, which is one of your
original suggestions, and it works like a champ. Thank you for sticking
with me on this! You're a doll!

Douglas J. Steele said:
Sorry, but I'm running out of ideas!

Just for kicks, try adding a new text box to your form, and setting its
ControlSource property to =fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)
(complete with equal sign)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Kathy Webster said:
With the switchboard on screen, and my cursor blinking in the field, I
hit Ctrl+G, get the immediate window, and paste your string and press
enter. It displays the correct path (so far this is very exciting!)

I double checked, and repasted your value below...it is the
ControlSource property of my txtBox called [Text44] in the switchboard.
But it is still displaying #Name?.

Hey-ulp! (distress call from the southern belle semi-programmer)


If it didn't pop up any error messages when you tried to compile, then
the option will be greyed out until you make a change and the
application needs to be recompiled. In any case, that implies that you
copied the code correctly.

What happens if you go to the Immediate window (Ctrl-G), type

?fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

and hit Enter? Do you get the correct path? If you do, then it would
appear you've set the field up incorrectly on your switchboard. Where
exactly did you put =fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA) for
that field? (It needs to be in the ControlSource property)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


I did it, it seemed to work. Now the option is greyed out.

message What happens if you try to compile your application? (While you're in
the VB Editor, it's the first option on the Debug menu)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hi Doug. Glad you are back.
I named it UserPaths.
After pasting the code in, it seems to have added "Option Compare
Database" above the first commented line of the code.

message What did you name the module, Kathy?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hmm, I'm trying to display the user apps folder name in a field on
the switchboard form, just to see if it is even receiving the
information. The name of the field on the switchboard is
[UserPathLocation]. I already tried the equal sign, with the same
#Name? result.


message On Mon, 16 Oct 2006 17:38:33 GMT, "Kathy Webster"

-I made a field in the switchboard and set its control source to
fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

-The field is displaying #Name?

Use

=fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

This assumes that CSIDL_LOCAL_APPDATA is the name of a control on
the
switchboard form which contains the information that
fGetSpecialFolderLocation needs.

John W. Vinson[MVP]
 
Sorry, I've never tried automating Word, so I won't be able to help you on
this one.

One approach might be to include the user information in the query you're
using to create AccessData.txt.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Kathy Webster said:
One last thing...
I know this isn't officially in your realm, but since you've gotten me
this far...

How do I pass that information to Word?
Because after MSAccess saves its query result to the user's appsdata
folder as "AccessData.txt", MSAccess stores a form file in the same folder
called "mergeform.doc". Word then takes those 2 files and merges them.
The data source of "mergeform.doc" is "AccessData.txt".

The prior folder where all this was stored was c:\msAccessApp.
So my Word macro currently reads:

Documents.Open FileName:="C:\msAccessApp\mergeform.doc",
ConfirmConversions:= _
False, ReadOnly:=False, AddToRecentFiles:=False,
PasswordDocument:="", _
PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _
WritePasswordTemplate:="", Format:=wdOpenFormatAuto
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.Execute

...and the data source for mergform.doc was c:\msAccessApp\accessdata.txt

Again, my eternal thanks.

Kathy Webster said:
No go...so I put it in the form's OnLoad event, which is one of your
original suggestions, and it works like a champ. Thank you for sticking
with me on this! You're a doll!

Douglas J. Steele said:
Sorry, but I'm running out of ideas!

Just for kicks, try adding a new text box to your form, and setting its
ControlSource property to
=fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA) (complete with equal
sign)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


With the switchboard on screen, and my cursor blinking in the field, I
hit Ctrl+G, get the immediate window, and paste your string and press
enter. It displays the correct path (so far this is very exciting!)

I double checked, and repasted your value below...it is the
ControlSource property of my txtBox called [Text44] in the switchboard.
But it is still displaying #Name?.

Hey-ulp! (distress call from the southern belle semi-programmer)


message If it didn't pop up any error messages when you tried to compile, then
the option will be greyed out until you make a change and the
application needs to be recompiled. In any case, that implies that you
copied the code correctly.

What happens if you go to the Immediate window (Ctrl-G), type

?fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

and hit Enter? Do you get the correct path? If you do, then it would
appear you've set the field up incorrectly on your switchboard. Where
exactly did you put =fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)
for that field? (It needs to be in the ControlSource property)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


I did it, it seemed to work. Now the option is greyed out.

message What happens if you try to compile your application? (While you're
in the VB Editor, it's the first option on the Debug menu)

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hi Doug. Glad you are back.
I named it UserPaths.
After pasting the code in, it seems to have added "Option Compare
Database" above the first commented line of the code.

message What did you name the module, Kathy?

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Hmm, I'm trying to display the user apps folder name in a field
on the switchboard form, just to see if it is even receiving the
information. The name of the field on the switchboard is
[UserPathLocation]. I already tried the equal sign, with the
same #Name? result.


message On Mon, 16 Oct 2006 17:38:33 GMT, "Kathy Webster"

-I made a field in the switchboard and set its control source to
fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

-The field is displaying #Name?

Use

=fGetSpecialFolderLocation(CSIDL_LOCAL_APPDATA)

This assumes that CSIDL_LOCAL_APPDATA is the name of a control
on the
switchboard form which contains the information that
fGetSpecialFolderLocation needs.

John W. Vinson[MVP]
 
Back
Top